ensl.org/spec/support/controller/session_helpers.rb
2020-03-15 15:33:58 +02:00

17 lines
No EOL
344 B
Ruby

module Controllers
module SessionHelpers
def login_admin
user = Group.admins.first.user
login(user.username)
end
def login(username)
user = User.where(:username => username.to_s).first
request.session[:user] = user.id
end
def current_user
User.find(request.session[:user])
end
end
end