Module: Passportist::Helpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/passportist/helpers.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



19
20
21
# File 'lib/passportist/helpers.rb', line 19

def authenticate!
  redirect_to welcome_url unless logged_in?
end

#current_userObject



9
10
11
12
13
# File 'lib/passportist/helpers.rb', line 9

def current_user
  @current_user ||= User.find_by_token!(cookies[:auth_token]) if cookies[:auth_token]
rescue ActiveRecord::RecordNotFound
  cookies.delete(:auth_token); nil
end

#logged_in?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/passportist/helpers.rb', line 15

def logged_in?
  !! current_user
end