module Balrog::Guard
Contains authentication logic to check the user has been authenticated, and that the session hasn't expired.
Public Instance Methods
authenticated?(balrog_session)
click to toggle source
# File lib/balrog/guard.rb, line 4 def authenticated?(balrog_session) @balrog_session = balrog_session&.with_indifferent_access previously_authenticated? && still_valid? end
Private Instance Methods
previously_authenticated?()
click to toggle source
A method to check that the user has been authenticated before.
# File lib/balrog/guard.rb, line 12 def previously_authenticated? return false unless @balrog_session @balrog_session[:value] == 'authenticated' end
still_valid?()
click to toggle source
A method to check that the authentication has not expired.
# File lib/balrog/guard.rb, line 18 def still_valid? # If the user did not set configured the Balrog session # to expire, the cookie is valid. return true unless @balrog_session[:expiry_date] DateTime.current < @balrog_session[:expiry_date] end