revise_auth 0.6.0 → 0.7.1

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
  SHA256:
3
- metadata.gz: 1de4a4179dd70dbb344db212f06a055ed6641f877a42164d70470e40e8a1bb3c
4
- data.tar.gz: c0b9d5f458248ff21f1e87566fd66258b8c564f01fdafde62ab8051ec0979390
3
+ metadata.gz: af1f59c2cc31af3c629baf760d48610da836dd5d2b4c7221742cd12122cceb49
4
+ data.tar.gz: 67f9631b83dc0034a0394779c052614617f8b038be6027be59a85de7c280e3fc
5
5
  SHA512:
6
- metadata.gz: e9cd05318740e67028f89d798608bb7ee779b844321003def73c022aca05f18f82d7544af28a7020958779fc34e9bc9820eab69f5f4622ba57f66b343a469329
7
- data.tar.gz: e00041b1ec907eafae11c4b52e74807ecfa855f3ad8cd2e5e560ee6e5323c58fd4804d056ab47aa3e9380b15cc40e891ccb9fed654404d7666db927c6eb50bb1
6
+ metadata.gz: fa482292b597afabdb54d18b49045375f7c62f017826d222eac85d8cc7d8e0b8cb7a42eda3c383a512da00641b6638d49f84bf3f127d3f2e1e426e0700f3e53d
7
+ data.tar.gz: f942b60c9f169890bf4553526f32c8b6a5add8cbfbc5308d4f2bb12947bb615a4e7a0d09440e9963634fb3cda6322ab24ff5d9b382c6f4c21573f615e6187c92
@@ -1,5 +1,6 @@
1
1
  class ReviseAuth::RegistrationsController < ReviseAuthController
2
2
  before_action :authenticate_user!, except: [:new, :create]
3
+ before_action :require_unauthenticated, only: [:new, :create]
3
4
 
4
5
  def new
5
6
  @user = User.new
@@ -9,7 +10,7 @@ class ReviseAuth::RegistrationsController < ReviseAuthController
9
10
  @user = User.new(sign_up_params)
10
11
  if @user.save
11
12
  login(@user)
12
- redirect_to root_path
13
+ redirect_to resolve_after_register_path
13
14
  else
14
15
  render :new, status: :unprocessable_entity
15
16
  end
@@ -1,4 +1,8 @@
1
1
  class ReviseAuth::SessionsController < ReviseAuthController
2
+ before_action :require_unauthenticated, only: [:new, :create]
3
+
4
+ rate_limit(**ReviseAuth.login_rate_limit) if respond_to?(:rate_limit) && ReviseAuth.login_rate_limit.present?
5
+
2
6
  def new
3
7
  end
4
8
 
@@ -16,14 +20,4 @@ class ReviseAuth::SessionsController < ReviseAuthController
16
20
  logout
17
21
  redirect_to root_path
18
22
  end
19
-
20
- private
21
-
22
- def resolve_after_login_path
23
- try(:after_login_path) || return_to_location || root_path
24
- end
25
-
26
- def return_to_location
27
- session.delete(:user_return_to)
28
- end
29
23
  end
@@ -1,2 +1,2 @@
1
- class ReviseAuthController < ApplicationController
1
+ class ReviseAuthController < ::ApplicationController
2
2
  end
@@ -53,8 +53,9 @@ data:
53
53
  # Find translate calls
54
54
  search:
55
55
  ## Paths or `Find.find` patterns to search in:
56
- # paths:
57
- # - app/
56
+ paths:
57
+ - app/
58
+ - lib/
58
59
 
59
60
  ## Root directories for relative keys resolution.
60
61
  # relative_roots:
@@ -61,6 +61,7 @@ cs:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ de:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ el:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ en:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ es:
61
61
  new:
62
62
  log_in: Iniciar sesión
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Iniciar sesión
66
67
  reset_password: Resetear contraseña
@@ -61,6 +61,7 @@ fr:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ nl:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ pt:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ tr:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -61,6 +61,7 @@ zh-TW:
61
61
  new:
62
62
  log_in: Log in
63
63
  shared:
64
+ already_authenticated: You are already signed in.
64
65
  links:
65
66
  log_in: Log in
66
67
  reset_password: Reset your password
@@ -25,6 +25,10 @@ module ReviseAuth
25
25
  redirect_to_login_with_stashed_location unless user_signed_in?
26
26
  end
27
27
 
28
+ def require_unauthenticated
29
+ redirect_to resolve_after_login_path, alert: t("revise_auth.shared.already_authenticated") if user_signed_in?
30
+ end
31
+
28
32
  # Authenticates the current user
29
33
  # - from session cookie
30
34
  # - (future) from Authorization header
@@ -61,9 +65,21 @@ module ReviseAuth
61
65
  session[:user_return_to] = path
62
66
  end
63
67
 
68
+ def return_to_location
69
+ session.delete(:user_return_to)
70
+ end
71
+
64
72
  def redirect_to_login_with_stashed_location
65
73
  stash_return_to_location(request.fullpath) if request.get?
66
- redirect_to login_path, alert: I18n.t("revise_auth.sign_up_or_login")
74
+ redirect_to login_path, alert: t("revise_auth.sign_up_or_login")
75
+ end
76
+
77
+ def resolve_after_register_path
78
+ try(:after_register_path) || return_to_location || root_path
79
+ end
80
+
81
+ def resolve_after_login_path
82
+ try(:after_login_path) || return_to_location || root_path
67
83
  end
68
84
 
69
85
  # Return true if it's a revise_auth_controller. false to all controllers unless
@@ -1,3 +1,3 @@
1
1
  module ReviseAuth
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.1"
3
3
  end
data/lib/revise_auth.rb CHANGED
@@ -17,4 +17,5 @@ module ReviseAuth
17
17
  config_accessor :sign_up_params, default: [:email, :password, :password_confirmation]
18
18
  config_accessor :update_params, default: []
19
19
  config_accessor :minimum_password_length, default: 12
20
+ config_accessor :login_rate_limit, default: {to: 10, within: 3.minutes, only: :create}
20
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revise_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-01 00:00:00.000000000 Z
11
+ date: 2024-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,7 +94,7 @@ metadata:
94
94
  homepage_uri: https://github.com/excid3/revise_auth
95
95
  source_code_uri: https://github.com/excid3/revise_auth
96
96
  changelog_uri: https://github.com/excid3/revise_auth/blob/main/CHANGELOG.md
97
- post_install_message:
97
+ post_install_message:
98
98
  rdoc_options: []
99
99
  require_paths:
100
100
  - lib
@@ -109,8 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.5.9
113
- signing_key:
112
+ rubygems_version: 3.5.14
113
+ signing_key:
114
114
  specification_version: 4
115
115
  summary: Simple authentication for Ruby on Rails apps
116
116
  test_files: []