Migrate to Postgresql for better network handling. Add more user functionality.

This commit is contained in:
Dan Milne
2025-11-06 14:08:39 +11:00
parent 85252a1a07
commit fc567f0b91
69 changed files with 4266 additions and 952 deletions

View File

@@ -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