Sha256: 26961ecf8875144913243a39ad231511b80cc82f13a8ae6492dc8ef7aa774232

Contents?: true

Size: 930 Bytes

Versions: 10

Compression:

Stored size: 930 Bytes

Contents

class UserTasks < Volt::Task
  # Login a user, takes a login and password.  Login can be either a username
  # or an e-mail based on Volt.config.public.auth.use_username
  #
  # login_info is a key with login and password (login may be e-mail)
  def login(login_info)
    login = login_info['login']
    password = login_info['password']

    query = { User.login_field => login }

    # During login we need access to the user's info even though we aren't the user
    Volt.skip_permissions do
      store._users.where(query).first.then do |user|
        fail VoltUserError, 'User could not be found' unless user

        match_pass = BCrypt::Password.new(user._hashed_password)
        fail 'Password did not match' unless  match_pass == password

        next Volt.user_login_signature(user)
      end
    end
  end

  def logout
    # Remove user_id from user's channel
    @channel.update_user_id(nil) if @channel
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
volt-0.9.7.pre8 app/volt/tasks/user_tasks.rb
volt-0.9.7.pre7 app/volt/tasks/user_tasks.rb
volt-0.9.7.pre6 app/volt/tasks/user_tasks.rb
volt-0.9.7.pre5 app/volt/tasks/user_tasks.rb
volt-0.9.7.pre3 app/volt/tasks/user_tasks.rb
volt-0.9.7.pre2 app/volt/tasks/user_tasks.rb
volt-0.9.6 app/volt/tasks/user_tasks.rb
volt-0.9.6.pre3 app/volt/tasks/user_tasks.rb
volt-0.9.6.pre2 app/volt/tasks/user_tasks.rb
volt-0.9.6.pre1 app/volt/tasks/user_tasks.rb