current_admin to current_user => prep for pundit

This commit is contained in:
Mark Moser
2016-09-19 14:25:17 -05:00
parent 3c45527a04
commit 0a69eb578e
7 changed files with 19 additions and 22 deletions

View File

@ -1,16 +1,16 @@
# frozen_string_literal: true
module Admin
class AuthController < AdminController
skip_before_action :authorize_admin
skip_before_action :authorize_user
def login
end
def auth
admin = User.find_by(email: auth_params[:email], role: 'admin')
user = User.find_by(email: auth_params[:email])
if admin && admin.authenticate(auth_params[:password])
session[:user] = admin.to_i
if user && user.authenticate(auth_params[:password])
session[:user] = user.to_i
redirect_to admin_path
else
redirect_to admin_login_path,

View File

@ -5,11 +5,11 @@ module Admin
end
def edit
@user = current_admin
@user = current_user
end
def update
@user = current_admin
@user = current_user
if @user.update_attributes(user_params)
redirect_to admin_profile_path,