Move status checking to model

This commit is contained in:
2023-05-02 03:17:41 +02:00
parent 74db85f26a
commit cc65b64a4b
3 changed files with 14 additions and 7 deletions

View File

@@ -1,17 +1,19 @@
class ApplicationController < ActionController::Base
helper_method :current_user_at_least
before_action :authenticate_user!
class AccessForbidden < StandardError
end
def current_user_at_least(status)
User.statuses[current_user.status] >= User.statuses[status]
end
protected
def after_sign_in_path_for(scope)
if current_user.at_least(:admin)
users_path
else
edit_user_registration_path
end
end
def after_sign_out_path_for(scope)
new_user_session_path
end