Class: UserTasks
- Inherits:
-
Volt::TaskHandler
- Object
- Volt::TaskHandler
- UserTasks
- Defined in:
- app/volt/tasks/user_tasks.rb
Instance Method Summary collapse
-
#login(username, password) ⇒ Object
Login a user, takes a username and password.
Methods inherited from Volt::TaskHandler
inherited, #initialize, known_handlers, method_missing, #store
Constructor Details
This class inherits a constructor from Volt::TaskHandler
Instance Method Details
#login(username, password) ⇒ Object
Login a user, takes a username and password
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/volt/tasks/user_tasks.rb', line 4 def login(username, password) puts "META: " + Thread.current['meta'].inspect if Volt.user puts "USER: " + Volt.user._name end return store._users.find(username: username).then do |users| user = users.first match_pass = BCrypt::Password.new(user._hashed_password) if match_pass == password raise "app_secret is not configured" unless Volt.config.app_secret # TODO: returning here should be possible, but causes some issues # Salt the user id with the app_secret so the end user can't tamper with the cookie signature = BCrypt::Password.create("#{Volt.config.app_secret}::#{user._id}") # Return user_id:hash on user id next "#{user._id}:#{signature}" else raise "Password did not match" end end end |