Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
require 'securerandom'
require 'models/user'
require 'interactors/find_user'
require 'repository'
class LogUserIn
attr_reader :login_type
def initialize(login_type)
@login_type = login_type
end
def run(login, password)
user = FindUser.by_login login
if user && user.password == password
user.set_login_token @login_type, new_login_token
Repository.for(User).save(user)
user
else
nil
end
end
protected
def new_login_token
SecureRandom.hex(32)
end
end