Module: Sorcery::Controller::Config

Defined in:
lib/sorcery/controller/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.after_failed_loginObject

Returns the value of attribute after_failed_login.



18
19
20
# File 'lib/sorcery/controller/config.rb', line 18

def 
  @after_failed_login
end

.after_loginObject

Returns the value of attribute after_login.



17
18
19
# File 'lib/sorcery/controller/config.rb', line 17

def 
  @after_login
end

.after_logoutObject

Returns the value of attribute after_logout.



20
21
22
# File 'lib/sorcery/controller/config.rb', line 20

def after_logout
  @after_logout
end

.after_remember_meObject

Returns the value of attribute after_remember_me.



21
22
23
# File 'lib/sorcery/controller/config.rb', line 21

def after_remember_me
  @after_remember_me
end

.before_logoutObject

Returns the value of attribute before_logout.



19
20
21
# File 'lib/sorcery/controller/config.rb', line 19

def before_logout
  @before_logout
end

set domain option for cookies



14
15
16
# File 'lib/sorcery/controller/config.rb', line 14

def cookie_domain
  @cookie_domain
end

.login_sourcesObject

Returns the value of attribute login_sources.



16
17
18
# File 'lib/sorcery/controller/config.rb', line 16

def 
  @login_sources
end

.not_authenticated_actionObject

what controller action to call for non-authenticated users.



9
10
11
# File 'lib/sorcery/controller/config.rb', line 9

def not_authenticated_action
  @not_authenticated_action
end

.save_return_to_urlObject

when a non logged in user tries to enter a page that requires login, save the URL he wanted to reach, and send him there after login.



12
13
14
# File 'lib/sorcery/controller/config.rb', line 12

def save_return_to_url
  @save_return_to_url
end

.submodulesObject

Returns the value of attribute submodules.



5
6
7
# File 'lib/sorcery/controller/config.rb', line 5

def submodules
  @submodules
end

.user_classObject

what class to use as the user class.



7
8
9
# File 'lib/sorcery/controller/config.rb', line 7

def user_class
  @user_class
end

Class Method Details

.configure(&blk) ⇒ Object



56
57
58
# File 'lib/sorcery/controller/config.rb', line 56

def configure(&blk)
  @configure_blk = blk
end

.configure!Object



60
61
62
# File 'lib/sorcery/controller/config.rb', line 60

def configure!
  @configure_blk.call(self) if @configure_blk
end

.init!Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sorcery/controller/config.rb', line 23

def init!
  @defaults = {
    :@user_class                           => nil,
    :@submodules                           => [],
    :@not_authenticated_action             => :not_authenticated,
    :@login_sources                        => Set.new,
    :@after_login                          => Set.new,
    :@after_failed_login                   => Set.new,
    :@before_logout                        => Set.new,
    :@after_logout                         => Set.new,
    :@after_remember_me                    => Set.new,
    :@save_return_to_url                   => true,
    :@cookie_domain                        => nil
  }
end

.reset!Object

Resets all configuration options to their default values.



40
41
42
43
44
# File 'lib/sorcery/controller/config.rb', line 40

def reset!
  @defaults.each do |k, v|
    instance_variable_set(k, v)
  end
end

.update!Object



46
47
48
49
50
# File 'lib/sorcery/controller/config.rb', line 46

def update!
  @defaults.each do |k, v|
    instance_variable_set(k, v) unless instance_variable_defined?(k)
  end
end

.user_config(&blk) ⇒ Object



52
53
54
# File 'lib/sorcery/controller/config.rb', line 52

def user_config(&blk)
  block_given? ? @user_config = blk : @user_config
end