monban 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/NEWS.rdoc +4 -0
- data/README.md +15 -3
- data/lib/monban/configuration.rb +10 -2
- data/lib/monban/version.rb +2 -2
- data/spec/monban/controller_helpers_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4882c70c08f77f8bee4a55815cb3021bdae77dc
|
4
|
+
data.tar.gz: 1d9890913a18365a2fcc6b0399cf14c7f9c03689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efbf4a103f0a617c39360272b77cd4f34a58426ad7964e3906fedea7e57e47ac684c02b19e608a10c4ec3f0326648ba6060987287ba45fa9b2257136e5a1109c
|
7
|
+
data.tar.gz: dad1fc0d96b979bef0337472c99e22ca4b8b8b8afdfdee0f7c058201ac485abf25694a60313db44887f418d6f6464e70275a1c44ade7f307b365a23254c423b3
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
monban (1.
|
4
|
+
monban (1.1.0)
|
5
5
|
bcrypt
|
6
6
|
rails
|
7
7
|
warden
|
@@ -120,10 +120,10 @@ GEM
|
|
120
120
|
rspec-mocks (~> 3.3.0)
|
121
121
|
rspec-support (~> 3.3.0)
|
122
122
|
rspec-support (3.3.0)
|
123
|
-
sprockets (3.6.
|
123
|
+
sprockets (3.6.3)
|
124
124
|
concurrent-ruby (~> 1.0)
|
125
125
|
rack (> 1, < 3)
|
126
|
-
sprockets-rails (3.
|
126
|
+
sprockets-rails (3.1.1)
|
127
127
|
actionpack (>= 4.0)
|
128
128
|
activesupport (>= 4.0)
|
129
129
|
sprockets (>= 3.0.0)
|
@@ -150,4 +150,4 @@ DEPENDENCIES
|
|
150
150
|
sqlite3
|
151
151
|
|
152
152
|
BUNDLED WITH
|
153
|
-
1.
|
153
|
+
1.12.5
|
data/NEWS.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.1.0
|
2
|
+
* `Monban.config.sign_in_notice` should now be a callable object in order for I18n to work correctly
|
3
|
+
* [DEPRECATED] you should no longer set `Monban.config.sign_in_notice` to a string value
|
4
|
+
|
1
5
|
== 1.0.1
|
2
6
|
* Wrap helper_method calls in respond_to?(:helper_method)
|
3
7
|
* param_transformations now correctly use string keys
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ If you're trying to sign up a User in a console you won't be able to call User#n
|
|
63
63
|
You should instead use the sign up service in order to create the user:
|
64
64
|
|
65
65
|
```ruby
|
66
|
-
Monban.config.sign_up_service.new(email: "foo@example.com", password: "password").perform
|
66
|
+
Monban.config.sign_up_service.new(email: "foo@example.com", password: "password").perform
|
67
67
|
```
|
68
68
|
|
69
69
|
#### Validations
|
@@ -122,6 +122,18 @@ end
|
|
122
122
|
|
123
123
|
This article on the [Null Object Pattern](http://robots.thoughtbot.com/handling-associations-on-null-objects) provides a good explanation of why you might want to do this.
|
124
124
|
|
125
|
+
#### Using I18n for sign in notice
|
126
|
+
|
127
|
+
If you want to use I18n for the notice instructing users to sign in when they try to access an unauthorized page you can do so with the following configuration:
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
Monban.configure do |config|
|
131
|
+
config.sign_in_notice = -> { I18n.t("sign_in_notice") }
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
It is suggested to store this file at `config/initializers/monban.rb`
|
136
|
+
|
125
137
|
### Controller Additions
|
126
138
|
|
127
139
|
Monban provides the following controller methods:
|
@@ -328,7 +340,7 @@ Monban::Configuration has lots of options for changing how monban works. Current
|
|
328
340
|
* **user_lookup_field**: (default `:email`) Field in the database to lookup a user by.
|
329
341
|
* **user_token_field**: (default `:password`) Field the form submits containing the undigested password.
|
330
342
|
* **user_token_store_field**: (default: `:password_digest`) Field in the database that stores the user's digested password.
|
331
|
-
* **user_class**: (default: `User`) The user class.
|
343
|
+
* **user_class**: (default: `'User'`) The user class.
|
332
344
|
|
333
345
|
### Services
|
334
346
|
|
@@ -363,7 +375,7 @@ Here are a few of the current limitations of monban:
|
|
363
375
|
|
364
376
|
## Contributing
|
365
377
|
|
366
|
-
1. Fork it
|
378
|
+
1. [Fork it](https://github.com/halogenandtoast/monban/fork)
|
367
379
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
368
380
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
369
381
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/monban/configuration.rb
CHANGED
@@ -75,7 +75,15 @@ module Monban
|
|
75
75
|
# @see #no_login_redirect
|
76
76
|
def default_no_login_handler
|
77
77
|
->(controller) do
|
78
|
-
|
78
|
+
notice = Monban.config.sign_in_notice
|
79
|
+
|
80
|
+
if notice.respond_to?(:call)
|
81
|
+
controller.flash.notice = notice.call
|
82
|
+
else
|
83
|
+
warn "[DEPRECATION] `Monban.config.sign_in_notice` should be a lambda instead of a string"
|
84
|
+
controller.flash.notice = notice
|
85
|
+
end
|
86
|
+
|
79
87
|
controller.redirect_to Monban.config.no_login_redirect
|
80
88
|
end
|
81
89
|
end
|
@@ -95,7 +103,7 @@ module Monban
|
|
95
103
|
end
|
96
104
|
|
97
105
|
def setup_notices
|
98
|
-
@sign_in_notice = 'You must be signed in'
|
106
|
+
@sign_in_notice = -> { 'You must be signed in' }
|
99
107
|
end
|
100
108
|
|
101
109
|
def setup_class_defaults
|
data/lib/monban/version.rb
CHANGED
@@ -148,7 +148,7 @@ module Monban
|
|
148
148
|
@dummy.require_login
|
149
149
|
expect(@dummy.redirected).to eq(true)
|
150
150
|
expect(@dummy.redirected_to).to eq(Monban.config.no_login_redirect)
|
151
|
-
expect(@dummy.flash.notice).to eq(Monban.config.sign_in_notice)
|
151
|
+
expect(@dummy.flash.notice).to eq(Monban.config.sign_in_notice.call)
|
152
152
|
end
|
153
153
|
|
154
154
|
it 'does not redirect when signed_in' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- halogenandtoast
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|