Skip to content

Commit

Permalink
refactor: refactor controller delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcooke committed May 2, 2023
1 parent f153d72 commit cf0786b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions lib/authie/controller_delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def set_browser_id
#
# @return [Authie::Session, false]
def validate_auth_session
return auth_session.validate if logged_in?
return false unless logged_in?

false
auth_session.validate
end

# Touch the session to update details on the latest activity.
Expand All @@ -74,27 +74,24 @@ def current_user
#
# @return [Authie::Session, nil]
def create_auth_session(user, **kwargs)
if user
@auth_session = Authie::Session.start(@controller, user: user, **kwargs)
return @auth_session
if user.nil?
invalidate_auth_session
return nil
end

invalidate_auth_session
nil
@auth_session = Authie::Session.start(@controller, user: user, **kwargs)
end

# Invalidate the existing auth session if one exists. Return true if a sesion has been invalidated
# otherwise return false.
#
# @return [Boolean]
def invalidate_auth_session
if logged_in?
auth_session.invalidate
@auth_session = nil
return true
end
return false unless logged_in?

false
auth_session.invalidate
@auth_session = nil
true
end

# Is anyone currently logged in? Return true if there is an auth session present.
Expand Down

0 comments on commit cf0786b

Please sign in to comment.