nyauth 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -0
- data/app/controllers/nyauth/reset_passwords_controller.rb +3 -0
- data/app/models/concerns/nyauth/confirmable.rb +2 -2
- data/app/models/concerns/nyauth/reset_password_ability.rb +3 -3
- data/app/services/nyauth/session_service.rb +2 -2
- data/config/locales/en.yml +7 -20
- data/config/locales/ja.yml +33 -0
- data/lib/generators/nyauth/templates/nyauth_install_initializer.rb +2 -0
- data/lib/nyauth/configuration.rb +4 -0
- data/lib/nyauth/engine.rb +0 -2
- data/lib/nyauth/version.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1876 -0
- data/spec/dummy/log/test.log +5625 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/featrues/nyauth/reset_password_requests_spec.rb +0 -4
- data/spec/featrues/nyauth/sessions_spec.rb +2 -2
- data/spec/lib/generators/nyauth/install_generator_spec.rb +11 -2
- metadata +5 -6
- data/app/assets/javascripts/nyauth/application.js +0 -13
- data/app/assets/stylesheets/nyauth/application.css +0 -15
- data/config/application.yml +0 -1
- data/lib/tasks/nyauth_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a34d8d2548f9a885e7460318e03b5b4f99c7041
|
4
|
+
data.tar.gz: 66c7edf2dd7f42f166e55fe5f9aebad192ebbf24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17a52d6ab151cce6bd3f54576ba56b4977f9d1195d0ef15963c37eeee941e339f08507be7fccd2321b373c5acc29bcf60652aeda0bd3a28877c014dee7fa68ef
|
7
|
+
data.tar.gz: 297bfd29c5fa6581ea4509433e5af0ab9e7f1f394b83d87152643e6fea0dca8c91dd1bccb46f058070fe16b4a453ade7d9c767052d2e1053e3097f9eb9c56c47
|
data/README.md
CHANGED
@@ -130,6 +130,8 @@ Or edit `config/initializers/nyauth.rb`
|
|
130
130
|
```
|
131
131
|
nyauth.configure do |config|
|
132
132
|
config.encryption_secret = ENV['NYAUTH_ENCRYPTION_SECRET'] || ENV['SECRET_KEY_BASE']
|
133
|
+
config.confirmation_expire_limit = 1.hour
|
134
|
+
config.reset_password_expire_limit = 1.hour
|
133
135
|
config.redirect_path do |urls|
|
134
136
|
# config.redirect_path_after_sign_in = -> (client_name) {
|
135
137
|
# if client_name == :admin
|
@@ -149,3 +151,41 @@ nyauth.configure do |config|
|
|
149
151
|
end
|
150
152
|
end
|
151
153
|
```
|
154
|
+
|
155
|
+
I18n
|
156
|
+
|
157
|
+
```
|
158
|
+
ja:
|
159
|
+
flash:
|
160
|
+
nyauth:
|
161
|
+
passwords:
|
162
|
+
update:
|
163
|
+
notice: 'パスワードを更新しました'
|
164
|
+
registrations:
|
165
|
+
create:
|
166
|
+
notice: '登録完了しました'
|
167
|
+
sessions:
|
168
|
+
create:
|
169
|
+
notice: 'ログインしました'
|
170
|
+
destroy:
|
171
|
+
notice: 'ログアウトしました'
|
172
|
+
confirmations:
|
173
|
+
update:
|
174
|
+
notice: 'メールアドレスの確認をしました'
|
175
|
+
confirmation_requests:
|
176
|
+
create:
|
177
|
+
notice: 'メールアドレスへ確認メールを送信しました'
|
178
|
+
reset_password_requests:
|
179
|
+
create:
|
180
|
+
notice: 'メールアドレスへパスワードリセットの案内を送信しました'
|
181
|
+
reset_passwords:
|
182
|
+
update:
|
183
|
+
notice: 'パスワードを再設定しました'
|
184
|
+
activerecord:
|
185
|
+
errors:
|
186
|
+
messages:
|
187
|
+
key_expired: 'URLの有効期限が切れてしまいました'
|
188
|
+
errors:
|
189
|
+
messages:
|
190
|
+
invalid_email_or_password: 'ログイン情報に誤りがあります'
|
191
|
+
```
|
@@ -17,7 +17,7 @@ module Nyauth
|
|
17
17
|
|
18
18
|
def request_confirmation
|
19
19
|
self.confirmation_key = SecureRandom.hex(32)
|
20
|
-
self.confirmation_key_expired_at = Time.current +
|
20
|
+
self.confirmation_key_expired_at = Time.current + Nyauth.configuration.confirmation_expire_limit
|
21
21
|
save
|
22
22
|
end
|
23
23
|
|
@@ -25,7 +25,7 @@ module Nyauth
|
|
25
25
|
|
26
26
|
def check_confirmation_key
|
27
27
|
if confirmation_key_expired_at.past?
|
28
|
-
errors.add(:confirmation_key, :
|
28
|
+
errors.add(:confirmation_key, :key_expired)
|
29
29
|
else
|
30
30
|
self.confirmation_key = nil
|
31
31
|
end
|
@@ -3,7 +3,7 @@ module Nyauth
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
before_validation :check_reset_password_key, on:
|
6
|
+
before_validation :check_reset_password_key, on: %i(reset_password edit_reset_password)
|
7
7
|
validates :password, presence: true,
|
8
8
|
length: { minimum: Nyauth.configuration.password_minium },
|
9
9
|
on: [:create, :update_password, :reset_password]
|
@@ -17,7 +17,7 @@ module Nyauth
|
|
17
17
|
|
18
18
|
def request_reset_password
|
19
19
|
self.reset_password_key = SecureRandom.hex(32)
|
20
|
-
self.reset_password_key_expired_at = Time.current +
|
20
|
+
self.reset_password_key_expired_at = Time.current + Nyauth.configuration.reset_password_expire_limit
|
21
21
|
save
|
22
22
|
end
|
23
23
|
|
@@ -25,7 +25,7 @@ module Nyauth
|
|
25
25
|
|
26
26
|
def check_reset_password_key
|
27
27
|
if reset_password_key_expired_at.past?
|
28
|
-
errors.add(:reset_password_key, :
|
28
|
+
errors.add(:reset_password_key, :key_expired)
|
29
29
|
else
|
30
30
|
self.reset_password_key = nil
|
31
31
|
end
|
@@ -12,10 +12,10 @@ module Nyauth
|
|
12
12
|
options.reverse_merge!(as: :user)
|
13
13
|
klass = options[:as].to_s.classify.constantize
|
14
14
|
@client = klass.authenticate(email, password)
|
15
|
-
errors.add(:
|
15
|
+
errors.add(:base, :invalid_email_or_password) unless @client
|
16
16
|
client
|
17
17
|
rescue
|
18
|
-
errors.add(:
|
18
|
+
errors.add(:base, :invalid_email_or_password)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/config/locales/en.yml
CHANGED
@@ -1,23 +1,6 @@
|
|
1
1
|
en:
|
2
|
-
nav:
|
3
|
-
sessions:
|
4
|
-
new: 'Sign in'
|
5
|
-
destroy: 'Sign out'
|
6
|
-
registrations:
|
7
|
-
new: 'Sign up'
|
8
|
-
profiles:
|
9
|
-
edit: 'Edit Profiles'
|
10
|
-
confirmation_requests:
|
11
|
-
new: 'Re send confirmation request'
|
12
|
-
reset_password_requests:
|
13
|
-
new: 'New password request'
|
14
|
-
profiles:
|
15
|
-
edit: 'Profiles'
|
16
2
|
flash:
|
17
3
|
nyauth:
|
18
|
-
profiles:
|
19
|
-
update:
|
20
|
-
notice: 'updated profiles'
|
21
4
|
passwords:
|
22
5
|
update:
|
23
6
|
notice: 'updated password'
|
@@ -41,6 +24,10 @@ en:
|
|
41
24
|
reset_passwords:
|
42
25
|
update:
|
43
26
|
notice: 'updated password'
|
44
|
-
|
45
|
-
|
46
|
-
|
27
|
+
activerecord:
|
28
|
+
errors:
|
29
|
+
messages:
|
30
|
+
key_expired: 'This URL is expired'
|
31
|
+
errors:
|
32
|
+
messages:
|
33
|
+
invalid_email_or_password: 'Invalid email or password'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
ja:
|
2
|
+
flash:
|
3
|
+
nyauth:
|
4
|
+
passwords:
|
5
|
+
update:
|
6
|
+
notice: 'パスワードを更新しました'
|
7
|
+
registrations:
|
8
|
+
create:
|
9
|
+
notice: '登録完了しました'
|
10
|
+
sessions:
|
11
|
+
create:
|
12
|
+
notice: 'ログインしました'
|
13
|
+
destroy:
|
14
|
+
notice: 'ログアウトしました'
|
15
|
+
confirmations:
|
16
|
+
update:
|
17
|
+
notice: 'メールアドレスの確認をしました'
|
18
|
+
confirmation_requests:
|
19
|
+
create:
|
20
|
+
notice: 'メールアドレスへ確認メールを送信しました'
|
21
|
+
reset_password_requests:
|
22
|
+
create:
|
23
|
+
notice: 'メールアドレスへパスワードリセットの案内を送信しました'
|
24
|
+
reset_passwords:
|
25
|
+
update:
|
26
|
+
notice: 'パスワードを再設定しました'
|
27
|
+
activerecord:
|
28
|
+
errors:
|
29
|
+
messages:
|
30
|
+
key_expired: 'URLの有効期限が切れてしまいました'
|
31
|
+
errors:
|
32
|
+
messages:
|
33
|
+
invalid_email_or_password: 'ログイン情報に誤りがあります'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
Nyauth.configure do |config|
|
2
2
|
config.encryption_secret = ENV['NYAUTH_ENCRYPTION_SECRET']
|
3
|
+
config.confirmation_expire_limit = 1.hour
|
4
|
+
config.reset_password_expire_limit = 1.hour
|
3
5
|
config.redirect_path do |urls|
|
4
6
|
# config.redirect_path_after_sign_in = -> (client_name) {
|
5
7
|
# if client_name == :admin
|
data/lib/nyauth/configuration.rb
CHANGED
@@ -9,6 +9,8 @@ module Nyauth
|
|
9
9
|
:redirect_path_after_reset_password_request,
|
10
10
|
:redirect_path_after_reset_password,
|
11
11
|
:redirect_path_after_update_password,
|
12
|
+
:confirmation_expire_limit,
|
13
|
+
:reset_password_expire_limit,
|
12
14
|
:password_minium,
|
13
15
|
:password_digest_stretches,
|
14
16
|
:encryption_secret
|
@@ -23,6 +25,8 @@ module Nyauth
|
|
23
25
|
@redirect_path_after_reset_password_request = Proc.new {}
|
24
26
|
@redirect_path_after_reset_password = Proc.new {}
|
25
27
|
@redirect_path_after_update_password = Proc.new {}
|
28
|
+
@confirmation_expire_limit = 1.hour
|
29
|
+
@reset_password_expire_limit = 1.hour
|
26
30
|
@password_minium = 8
|
27
31
|
@password_digest_stretches = 1000
|
28
32
|
@encryption_secret = ENV['NYAUTH_ENCRYPTION_SECRET']
|
data/lib/nyauth/engine.rb
CHANGED
@@ -10,8 +10,6 @@ module Nyauth
|
|
10
10
|
class Engine < ::Rails::Engine
|
11
11
|
isolate_namespace Nyauth
|
12
12
|
|
13
|
-
config.nyauth = ActiveSupport::OrderedOptions.new
|
14
|
-
config.nyauth.admin = 'admin'
|
15
13
|
config.i18n.load_path += Dir[Engine.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
|
16
14
|
config.generators do |g|
|
17
15
|
g.test_framework :rspec, fixture: false
|
data/lib/nyauth/version.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|