skill-assessment-app/app/controllers/admin/auth_controller.rb
2016-08-22 16:26:21 -05:00

26 lines
580 B
Ruby

module Admin
class AuthController < AdminController
skip_before_action :authorize_admin
def login
end
def auth
admin = User.find_by(email: auth_params[:email], role: 'admin')
if admin && admin.authenticate(auth_params[:password])
session[:user] = admin.to_i
redirect_to admin_path
else
redirect_to admin_login_path,
flash: { error: "Sorry, incorrect email or password. Please try again." }
end
end
def logout
reset_session
redirect_to admin_login_path
end
end
end