Migrate to Postgresql for better network handling. Add more user functionality.
This commit is contained in:
@@ -7,9 +7,13 @@ class ApplicationController < ActionController::Base
|
||||
stale_when_importmap_changes
|
||||
|
||||
include Pagy::Backend
|
||||
include Pagy::Frontend
|
||||
include Pundit::Authorization
|
||||
|
||||
helper_method :current_user, :user_signed_in?, :current_user_admin?, :current_user_viewer?
|
||||
|
||||
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
|
||||
|
||||
private
|
||||
|
||||
def current_user
|
||||
@@ -43,4 +47,12 @@ class ApplicationController < ActionController::Base
|
||||
def after_authentication_url
|
||||
session.delete(:return_to_after_authenticating) || root_url
|
||||
end
|
||||
|
||||
def user_not_authorized
|
||||
if user_signed_in?
|
||||
redirect_to root_path, alert: "You don't have permission to perform this action."
|
||||
else
|
||||
redirect_to new_session_path, alert: "Please sign in to continue."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user