current_admin to current_user => prep for pundit
This commit is contained in:
@ -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,
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user