authstrategies 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDQ4MGFkZTdlMTdlOGI5NGFiZGMyZTY0MWJhNWFiNzA2YjJkYzQ3ZA==
4
+ OTQ3YmIyY2QwNDJhNWJiMjk3YWE5MTdjZGFjNGY3NDA0ZDY4ZTk1Yw==
5
5
  data.tar.gz: !binary |-
6
- NTBkOWUwOGFlNGYzYzdhYzFkZjk2OTg0YmVlMDYyODRiMmVkNDIzMg==
6
+ OGJlYjQ4NjM3YWJkZjI5MGExNWM3YjgyZWU0ZTYxNGI5M2U1YmQxYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTI2ZTRkOGE3NmRhM2E0NWM1NjYxNDRlMWM4MzQ1OGYwYWYyNjQ0YmNiYjA0
10
- YmM0MWIyODVmMzAwZGNhMWUxMWUwODk2ZDBiNjRkY2I5OTY0Njg5MGUyZGE4
11
- NDAyMzU5N2VkZTQ4ZWYzOTU4NTY2Mjg1YWFiYzQwNmJhMzc1ODQ=
9
+ YWU5NmFhYmM4YzhjZDFlNmQ4OTFjZWI2ZDY4MzE3MTlkNzE4NDEzZDhjOTI5
10
+ Y2Y2NDdiYmQxYzA1NmFjY2MxZGZhNWE3MzU0MjU0MzdkNjZkNDBmNDYyM2M5
11
+ YmY4YWMxMDQ2ZTJjODUyN2QwNGY2OGVjNzI0N2Y5Njc4Nzc5ZTk=
12
12
  data.tar.gz: !binary |-
13
- Mjc3MTlmZDA3YjJiMjlhNGM3MGI4NzE0OWYyZTRlYmVmMGExMTJmZGUxNTE3
14
- ZTA5ZTA2OTY4M2E5MzBiN2UyODdlYTU2MmE4OWQ2NGI0NTZmOTgyNjgyNWM4
15
- MDE3YTBhN2UxN2EyNGZhNjVhOGEyYTQzODcxYTFmZWI2YTY5OTQ=
13
+ MDVkYWI0NTNhOWRhOWJmYjIwZDdkYWQ0YTI1MGY1YjA1N2VlNTFjZDE2NDA1
14
+ OTY1N2IxYzZkZjk4ZDE3OTU5OWM4MmNjZGIxOTY5Nzg2MjRmODk3Y2ExY2Q4
15
+ YTUwZmQ4YTEyMDIzMmFjNWMxNDBmNjE5OTQzMTA3N2NkZmFiZTU=
@@ -15,14 +15,16 @@ module Authstrategies
15
15
 
16
16
  @@callbacks = {}
17
17
 
18
- @@_after_login_path = '/'
19
- @@_after_login_msg = 'Successfully logged in!'
18
+ @@config = {
19
+ :after_login_path => '/',
20
+ :after_login_msg => 'Successfully logged in!',
20
21
 
21
- @@_after_logout_path = '/'
22
- @@_after_logout_msg = 'Successfully logged out!'
22
+ :after_logout_path => '/',
23
+ :after_logout_msg => 'Successfully logged out!',
23
24
 
24
- @@_after_signup_path = '/'
25
- @@_after_signup_msg = 'Successfully signed up!'
25
+ :after_signup_path => '/',
26
+ :after_signup_msg => 'Successfully signed up!',
27
+ }
26
28
 
27
29
  def self.registered? hook
28
30
  @@callbacks.has_key? hook
@@ -44,6 +46,11 @@ module Authstrategies
44
46
  end
45
47
  end
46
48
 
49
+ def self.config &block
50
+ yield(@@config) if block_given?
51
+ @@config
52
+ end
53
+
47
54
  # This is called every time the user is set. The user is set:
48
55
  # => on each request when they are accessed for the first time via env['warden'].user
49
56
  # => when the user is initially authenticated
@@ -102,22 +109,6 @@ module Authstrategies
102
109
  self.register :after_logout, &block
103
110
  end
104
111
 
105
- # This defines a path to redirect the user to
106
- # after he logs out and a flash message to print
107
- # path default is root path
108
- # message default is 'Logged out successfully!'
109
- def self.after_logout_path path, message
110
- @@_after_logout_path, @@after_logout_msg = path, message
111
- end
112
-
113
- def self._after_logout_path
114
- @@_after_logout_path
115
- end
116
-
117
- def self._after_logout_msg
118
- @@_after_logout_msg
119
- end
120
-
121
112
  # This is called each time after the user logs in
122
113
  # 3 parameters are passed to this callback
123
114
  # =>current_user - the user that hase just been set
@@ -127,22 +118,6 @@ module Authstrategies
127
118
  self.register :after_login, &block
128
119
  end
129
120
 
130
- # This defines a path to redirect the user to
131
- # after he logs in and a flash message to print
132
- # path default is root path
133
- # message default is 'Logged in successfully!'
134
- def self.after_login_path path, message
135
- @@_after_login_path, @@after_login_msg = path, message
136
- end
137
-
138
- def self._after_login_path
139
- @@_after_login_path
140
- end
141
-
142
- def self._after_login_msg
143
- @@after_login_msg
144
- end
145
-
146
121
  # This is called after the user is saved into
147
122
  # the database
148
123
  # 3 parameters are passed to this callback
@@ -154,15 +129,6 @@ module Authstrategies
154
129
  def self.after_signup &block
155
130
  self.register :after_signup, &block
156
131
  end
157
-
158
- # This defines a path to redirect the user to
159
- # after he signs up and a flash message to print
160
- # path default is root path
161
- # message default is 'Successfully signed up!
162
- def self.after_signup_path path, message
163
- @@_after_signup_path, @@after_signup_msg = path, message
164
- end
165
-
166
132
  end
167
133
 
168
134
  module Base
@@ -22,8 +22,8 @@ module Authstrategies
22
22
  )
23
23
  end
24
24
  Manager.call :after_login, [current_user, request, response]
25
- flash[:notice] = Manager._after_login_msg
26
- redirect Manager._after_login_path
25
+ flash[:notice] = Manager.config[:after_login_msg]
26
+ redirect Manager.config[:after_login_path]
27
27
  end
28
28
  end
29
29
 
@@ -39,8 +39,8 @@ module Authstrategies
39
39
  user.save
40
40
  env['warden'].set_user(user)
41
41
  Manager.call :after_signup, [user, request, response]
42
- flash[:notice] = Manager._after_signup_msg
43
- redirect Manager._after_signup_path
42
+ flash[:notice] = Manager.config[:after_signup_msg]
43
+ redirect Manager.config[:after_signup_path]
44
44
  else
45
45
  flash[:error] = user.errors.messages
46
46
  redirect '/signup'
@@ -53,8 +53,8 @@ module Authstrategies
53
53
  response.delete_cookie("authstrategies")
54
54
  logout
55
55
  Manager.call :after_logout, [request, response]
56
- flash[:notice] = Manager._after_logout_msg
57
- redirect Manager._after_logout_path
56
+ flash[:notice] = Manager.config[:after_logout_msg]
57
+ redirect Manager.config[:after_logout_path]
58
58
  end
59
59
  redirect '/'
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module Authstrategies
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authstrategies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dobromir Ivanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-04 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler