1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 23:59:40 +02:00

Opt-in to Current fully (#297)

This commit is contained in:
Dwight Watson 2024-02-05 10:36:46 +11:00 committed by GitHub
parent 23eaa3e066
commit d61a22b070
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 24 additions and 23 deletions

View file

@ -2,31 +2,21 @@ module Authentication
extend ActiveSupport::Concern
included do
helper_method :current_user
helper_method :current_family
helper_method :user_signed_in?
end
private
def authenticate_user!
redirect_to new_session_path unless user_signed_in?
end
def current_user
Current.user || authenticate_user_from_session
end
def current_family
current_user.family
end
def authenticate_user_from_session
User.find_by(id: session[:user_id])
if user = User.find_by(id: session[:user_id])
Current.user = user
else
redirect_to new_session_url
end
end
def user_signed_in?
current_user.present?
Current.user.present?
end
def login(user)