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

.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



54
55
56
# File 'lib/sorcery/controller/config.rb', line 54

def configure(&blk)
  @configure_blk = blk
end

.configure!Object



58
59
60
# File 'lib/sorcery/controller/config.rb', line 58

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

.init!Object



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

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

.reset!Object

Resets all configuration options to their default values.



38
39
40
41
42
# File 'lib/sorcery/controller/config.rb', line 38

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

.update!Object



44
45
46
47
48
# File 'lib/sorcery/controller/config.rb', line 44

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

.user_config(&blk) ⇒ Object



50
51
52
# File 'lib/sorcery/controller/config.rb', line 50

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