revise_auth 0.5.0 → 0.7.0

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: 82891afa84e7065812fdd1cc0df0ad42e095d0aa9ed8617f103ac3604f022bb0
4
- data.tar.gz: f13795454d91f4083a30039cbbc83d56789ba26ac3e96193784c129705e56aab
3
+ metadata.gz: 6a6403810d3c60e03cc0e09a4a756770fe53de27701578209642bbac3c080270
4
+ data.tar.gz: a04b03a82250b048aa26a7922ce984da15dd7270b45d1e277112a22e870f3d06
5
5
  SHA512:
6
- metadata.gz: dfcf294a0c3d681d2e9c3a1f446568d13313c632f484d6bdda5b3cff0a5c31cb50fef6865467ac16db054ddf93c22a65d4900f8f7fe83e8a61ea19f4ba5669ee
7
- data.tar.gz: f36f99adcac73323ad42aa9b6ec2902426a32d807f32add9155e259587232f16203bac64c679c7e97a874e913f7e0ea10bfd1453e3280287e9a9f3f877787abb
6
+ metadata.gz: 78f5d30aa78e0ce1fc7c25b1a33cc502a780fa23d55f93f2e6a2f939cab5378659abdb68f8bf132486f4268f3b5217e886dd42cb32c77c28b7f5aa3a2aae4b31
7
+ data.tar.gz: 2cc5056ce0b8007b4fec974a9a073c1bf68ef65334fe0161f70f6b1a371d82a12eec56fc41f0f11dad8d647da3244c6d6bc48cad1b2da78ac653a31585a501b8
data/README.md CHANGED
@@ -33,7 +33,7 @@ $ rails g revise_auth:model
33
33
  Optionally, you can add other fields such as `first_name` and `last_name`:
34
34
 
35
35
  ```bash
36
- $ rails g revise_auth:model User first_name last_name
36
+ $ rails g revise_auth:model first_name last_name
37
37
  ```
38
38
 
39
39
  And then run:
@@ -53,7 +53,7 @@ You can accomplish this in a few different ways:
53
53
 
54
54
  ### Routes
55
55
 
56
- Tell your router to add ReviseAuth's controllers:
56
+ The model generator will automatically add ReviseAuth's routes to your router:
57
57
 
58
58
  ```
59
59
  # config/routes.rb
@@ -140,6 +140,50 @@ authenticated do
140
140
  end
141
141
  ```
142
142
 
143
+ ### Password Length
144
+
145
+ The minimum acceptable password length for validation defaults to 12 characters but this can be configured in either `config/initializers/revise_auth.rb` or your environment configuration:
146
+
147
+ ```ruby
148
+ ReviseAuth.configure do |config|
149
+ config.minimum_password_length = 42
150
+ end
151
+ ```
152
+
153
+ ## Test helpers
154
+
155
+ ReviseAuth comes with handy helpers you can use in your tests:
156
+
157
+ ```ruby
158
+ # POST /login with the given user and password
159
+ login(user, password: "password")
160
+ # DELETE /logout
161
+ logout
162
+ ```
163
+
164
+ Include the `ReviseAuth::Test::Helpers` module to make them available in your tests.
165
+
166
+ ```ruby
167
+ class ActionDispatch::IntegrationTest
168
+ include ReviseAuth::Test::Helpers
169
+ end
170
+ ```
171
+
172
+ Then in your tests:
173
+
174
+ ```ruby
175
+ class MyControllerTest < ActionDispatch::IntegrationTest
176
+ setup do
177
+ @user = users(:bob)
178
+ login @user
179
+ end
180
+
181
+ test "..." do
182
+ # ...
183
+ end
184
+ end
185
+ ```
186
+
143
187
  ## Contributing
144
188
 
145
189
  If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.
@@ -9,7 +9,7 @@ class ReviseAuth::RegistrationsController < ReviseAuthController
9
9
  @user = User.new(sign_up_params)
10
10
  if @user.save
11
11
  login(@user)
12
- redirect_to root_path
12
+ redirect_to resolve_after_register_path
13
13
  else
14
14
  render :new, status: :unprocessable_entity
15
15
  end
@@ -41,4 +41,8 @@ class ReviseAuth::RegistrationsController < ReviseAuthController
41
41
  def profile_params
42
42
  params.require(:user).permit(ReviseAuth.update_params)
43
43
  end
44
+
45
+ def resolve_after_register_path
46
+ try(:after_register_path) || return_to_location || root_path
47
+ end
44
48
  end
@@ -22,8 +22,4 @@ class ReviseAuth::SessionsController < ReviseAuthController
22
22
  def resolve_after_login_path
23
23
  try(:after_login_path) || return_to_location || root_path
24
24
  end
25
-
26
- def return_to_location
27
- session.delete(:user_return_to)
28
- end
29
25
  end
@@ -1,2 +1,7 @@
1
- class ReviseAuthController < ApplicationController
1
+ class ReviseAuthController < ::ApplicationController
2
+ private
3
+
4
+ def return_to_location
5
+ session.delete(:user_return_to)
6
+ end
2
7
  end
@@ -18,3 +18,5 @@
18
18
  <%= form.button t(".send_password_reset_instructions") %>
19
19
  </div>
20
20
  <% end %>
21
+
22
+ <%= render "revise_auth/shared/links" %>
@@ -28,3 +28,5 @@
28
28
  <%= form.button t(".sign_up") %>
29
29
  </div>
30
30
  <% end %>
31
+
32
+ <%= render "revise_auth/shared/links" %>
@@ -14,8 +14,6 @@
14
14
  <div>
15
15
  <%= form.button t(".log_in") %>
16
16
  </div>
17
-
18
- <div>
19
- <%= link_to t(".reset_password"), new_password_reset_path %>
20
- </div>
21
17
  <% end %>
18
+
19
+ <%= render "revise_auth/shared/links" %>
@@ -0,0 +1,15 @@
1
+ <% if controller_name == "sessions" %>
2
+ <div>
3
+ <%= link_to t(".reset_password"), new_password_reset_path %>
4
+ </div>
5
+ <% else %>
6
+ <div>
7
+ <%= link_to t(".log_in"), login_path %>
8
+ </div>
9
+ <% end %>
10
+
11
+ <% if controller_name != "registrations" %>
12
+ <div>
13
+ <%= link_to t(".sign_up"), sign_up_path %>
14
+ </div>
15
+ <% end %>
@@ -60,5 +60,9 @@ cs:
60
60
  invalid_email_or_password: Neplatný e-mail nebo heslo.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Pro pokračování se zaregistruje nebo přihlaste
@@ -60,5 +60,9 @@ de:
60
60
  invalid_email_or_password: Ungültige Email oder Passwort.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Registrieren oder anmelden um fortzufahren.
@@ -60,5 +60,9 @@ el:
60
60
  invalid_email_or_password: Μη έγκυρο email ή κωδικός πρόσβασης.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Εγγραφείτε ή συνδεθείτε για να συνεχίσετε.
@@ -60,5 +60,9 @@ en:
60
60
  invalid_email_or_password: Invalid email or password.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Sign up or log in to continue.
@@ -60,5 +60,9 @@ es:
60
60
  invalid_email_or_password: Email o contraseña inválidas.
61
61
  new:
62
62
  log_in: Iniciar sesión
63
+ shared:
64
+ links:
65
+ log_in: Iniciar sesión
63
66
  reset_password: Resetear contraseña
67
+ sign_up: Registrate
64
68
  sign_up_or_login: Registrate o inicia sesión para continuar.
@@ -60,5 +60,9 @@ fr:
60
60
  invalid_email_or_password: Email ou mot de passe incorrect.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Vous devez être connecté ou vous enregistrer pour continuer.
@@ -60,5 +60,9 @@ nl:
60
60
  invalid_email_or_password: Ongeldige e-mail of wachtwoord.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Aanmelden of inloggen om door te gaan.
@@ -60,5 +60,9 @@ pt:
60
60
  invalid_email_or_password: Email ou password inválidos.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Registe-se ou clique em entrar para continuar.
@@ -60,5 +60,9 @@ tr:
60
60
  invalid_email_or_password: Geçersiz e-posta veya şifre.
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: Devam etmek için kaydol veya giriş yap.
@@ -60,5 +60,9 @@ zh-TW:
60
60
  invalid_email_or_password: 錯誤的信箱或是密碼
61
61
  new:
62
62
  log_in: Log in
63
+ shared:
64
+ links:
65
+ log_in: Log in
63
66
  reset_password: Reset your password
67
+ sign_up: Sign up
64
68
  sign_up_or_login: 需要註冊或是登入才能進行
@@ -20,6 +20,10 @@ module ReviseAuth
20
20
  inject_into_class "app/models/user.rb", "User", " include ReviseAuth::Model\n" if behavior == :invoke
21
21
  end
22
22
 
23
+ def add_revise_auth_routes
24
+ route "revise_auth"
25
+ end
26
+
23
27
  def copy_initializer
24
28
  template "initializer.rb", "config/initializers/revise_auth.rb"
25
29
  end
@@ -70,7 +70,7 @@ module ReviseAuth
70
70
  # the controllers defined inside revise_auth. Useful if you want to apply a before
71
71
  # filter to all controllers, except the ones in revise_auth:
72
72
  #
73
- # before_action :authenticate_user!, except: :revise_auth_controller?
73
+ # before_action :authenticate_user!, unless: :revise_auth_controller?
74
74
  def revise_auth_controller?
75
75
  is_a?(::ReviseAuthController)
76
76
  end
@@ -21,7 +21,7 @@ module ReviseAuth
21
21
 
22
22
  validates :email, format: {with: URI::MailTo::EMAIL_REGEXP}, presence: true, uniqueness: true
23
23
  validates :unconfirmed_email, format: {with: URI::MailTo::EMAIL_REGEXP}, allow_blank: true
24
- validates_length_of :password, minimum: 12, allow_nil: true
24
+ validates_length_of :password, minimum: ReviseAuth.minimum_password_length, allow_nil: true
25
25
  end
26
26
 
27
27
  # Generates a confirmation token and send email to the user
@@ -0,0 +1,16 @@
1
+ module ReviseAuth
2
+ module Test
3
+ module Helpers
4
+ def login(user, password: "password")
5
+ post login_path, params: {
6
+ email: user.email,
7
+ password: password
8
+ }
9
+ end
10
+
11
+ def logout
12
+ delete logout_path
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module ReviseAuth
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/revise_auth.rb CHANGED
@@ -3,13 +3,18 @@ require "revise_auth/engine"
3
3
  require "revise_auth/routes"
4
4
 
5
5
  module ReviseAuth
6
+ include ActiveSupport::Configurable
7
+
6
8
  autoload :Authentication, "revise_auth/authentication"
7
9
  autoload :Current, "revise_auth/current"
8
10
  autoload :Model, "revise_auth/model"
9
11
  autoload :RouteConstraint, "revise_auth/route_constraint"
10
12
 
11
- include ActiveSupport::Configurable
13
+ module Test
14
+ autoload :Helpers, "revise_auth/test/helpers"
15
+ end
12
16
 
13
- config_accessor :sign_up_params, default: [:name, :email, :password, :password_confirmation]
14
- config_accessor :update_params, default: [:name]
17
+ config_accessor :sign_up_params, default: [:email, :password, :password_confirmation]
18
+ config_accessor :update_params, default: []
19
+ config_accessor :minimum_password_length, default: 12
15
20
  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.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-17 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -62,6 +62,7 @@ files:
62
62
  - app/views/revise_auth/registrations/edit.html.erb
63
63
  - app/views/revise_auth/registrations/new.html.erb
64
64
  - app/views/revise_auth/sessions/new.html.erb
65
+ - app/views/revise_auth/shared/_links.html.erb
65
66
  - config/i18n-tasks.yml
66
67
  - config/locales/cs.yml
67
68
  - config/locales/de.yml
@@ -84,8 +85,8 @@ files:
84
85
  - lib/revise_auth/model.rb
85
86
  - lib/revise_auth/route_constraint.rb
86
87
  - lib/revise_auth/routes.rb
88
+ - lib/revise_auth/test/helpers.rb
87
89
  - lib/revise_auth/version.rb
88
- - lib/tasks/revise_auth_tasks.rake
89
90
  homepage: https://github.com/excid3/revise_auth
90
91
  licenses:
91
92
  - MIT
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.5.6
112
+ rubygems_version: 3.5.11
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: Simple authentication for Ruby on Rails apps
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :revise_auth do
3
- # # Task goes here
4
- # end