Class: J1WardenOmniAuth::Strategy

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
lib/j1_app/j1_auth_manager/warden_omniauth.rb

Overview

The base omniauth warden strategy. This is inherited for each omniauth strategy

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.omni_nameObject

Returns the value of attribute omni_name.



80
81
82
# File 'lib/j1_app/j1_auth_manager/warden_omniauth.rb', line 80

def omni_name
  @omni_name
end

Class Method Details

.on_callback(&blk) ⇒ Object

make a specific callback for this strategy



68
69
70
71
# File 'lib/j1_app/j1_auth_manager/warden_omniauth.rb', line 68

def self.on_callback(&blk)
  @on_callback = blk if blk
  @on_callback || J1WardenOmniAuth.on_callback
end

Instance Method Details

#authenticate!Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/j1_app/j1_auth_manager/warden_omniauth.rb', line 83

def authenticate!
  session = env[SESSION_KEY]
  session[SCOPE_KEY] = scope

  # set the user if exists otherwise redirect for authentication
  if user = (env['omniauth.auth'] || env['rack.auth'] || request['auth'])
    success! self.class.on_callback[user]
  else
    path_prefix = OmniAuth::Configuration.instance.path_prefix
    redirect! File.join(path_prefix, self.class.omni_name)
  end
end

#authenticated?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/j1_app/j1_auth_manager/warden_omniauth.rb', line 96

def authenticated?
  !session[:uid].nil?
end