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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81cfbcefaf5c3f92dbd8937cd999481e3863aed6
4
- data.tar.gz: ddad74740d111f1e0adbdd4689020ada40e8d4b0
3
+ metadata.gz: 8a34d8d2548f9a885e7460318e03b5b4f99c7041
4
+ data.tar.gz: 66c7edf2dd7f42f166e55fe5f9aebad192ebbf24
5
5
  SHA512:
6
- metadata.gz: 68e8227c95cd08c4fa2ec26ffd6b59d18aeaa23e5b1abde5241205c8ea4edce53375cb8da871c58a30a034d71e52184ffd743406c5826d1464d58a4cbadd4a56
7
- data.tar.gz: 3c3651402abd49496a1bbbac2398193b6d6f5decdcc070f3c3868fa98103e61013c1f3ec5f901fa51688bd8f389b4bfb50a4d517106dd71aa4dc9a36f77fcec2
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
+ ```
@@ -7,6 +7,9 @@ module Nyauth
7
7
  before_action :set_client
8
8
 
9
9
  def edit
10
+ unless @client.valid?(:edit_reset_password)
11
+ redirect_to new_session_path_for(client_name), alert: @client.errors[:reset_password_key].last
12
+ end
10
13
  end
11
14
 
12
15
  def update
@@ -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 + 1.hour
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, :expired)
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: :reset_password
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 + 1.hour
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, :expired)
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(:client, 'invalid email or password') unless @client
15
+ errors.add(:base, :invalid_email_or_password) unless @client
16
16
  client
17
17
  rescue
18
- errors.add(:client, 'invalid email or password')
18
+ errors.add(:base, :invalid_email_or_password)
19
19
  end
20
20
  end
21
21
  end
@@ -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
- group_requests:
45
- create:
46
- notice: 'sent request'
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Nyauth
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -12,7 +12,7 @@
12
12
  <% if flash[:notice] %>
13
13
  <%= flash[:notice] %>
14
14
  <% end %>
15
- <% if flash[:notice] %>
15
+ <% if flash[:alert] %>
16
16
  <%= flash[:alert] %>
17
17
  <% end %>
18
18
  <%= link_to "URL helper on application", posts_path %>
Binary file
Binary file