revise_auth 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af1f59c2cc31af3c629baf760d48610da836dd5d2b4c7221742cd12122cceb49
4
- data.tar.gz: 67f9631b83dc0034a0394779c052614617f8b038be6027be59a85de7c280e3fc
3
+ metadata.gz: 79aa6971d3ef0baa6c9100c6442f4de75c35f37b537b0e2a0455f44d839d2d70
4
+ data.tar.gz: 16d9e92024262b4d0afda327b787f6f68f0649912b4f6ab4289e252c24ecd4b2
5
5
  SHA512:
6
- metadata.gz: fa482292b597afabdb54d18b49045375f7c62f017826d222eac85d8cc7d8e0b8cb7a42eda3c383a512da00641b6638d49f84bf3f127d3f2e1e426e0700f3e53d
7
- data.tar.gz: f942b60c9f169890bf4553526f32c8b6a5add8cbfbc5308d4f2bb12947bb615a4e7a0d09440e9963634fb3cda6322ab24ff5d9b382c6f4c21573f615e6187c92
6
+ metadata.gz: a58172f8b5c0732c23512853edd2e71afa84d91dea4f32c168ac57f7dca59a4b5122aff06148caf52fc599d177253e034f5e26cbc26c6187d2e6d73205022844
7
+ data.tar.gz: cd7b8de9f806913bf8e1e1c0357982b27538f6508ae8c608f3827ae6bc24e8dd8df7d95cc9c0ecc8e1f9141af42e529eee9f3f1ce5201e4828fe8c0f5c33fe7c
data/README.md CHANGED
@@ -63,6 +63,17 @@ revise_auth
63
63
 
64
64
  You will want to define a root path. After login (see below), the user will be redirected to the root path.
65
65
 
66
+ ### Views
67
+
68
+ ReviseAuth uses the flash to display notices and alerts, so make sure flash messages are rendered by your application:
69
+
70
+ ```erb
71
+ <%# views/layouts/application.html.erb %>
72
+
73
+ <%= tag.div notice if notice %>
74
+ <%= tag.div alert if alert %>
75
+ ```
76
+
66
77
  ### Filters and Helpers
67
78
 
68
79
  To protect your actions from unauthenticated users, you can use the `authenticate_user!` filter:
@@ -6,9 +6,8 @@
6
6
  <% form.object.errors.full_messages.each do |message| %>
7
7
  <li><%= message %></li>
8
8
  <% end %>
9
- <% end %>
10
-
11
9
  </ul>
10
+ <% end %>
12
11
  <div>
13
12
  <%= form.label :email %>
14
13
  <%= form.email_field :email, required: true, autofocus: true %>
@@ -9,6 +9,12 @@ module ReviseAuth
9
9
  helper_method :current_user
10
10
  end
11
11
 
12
+ class_methods do
13
+ def authenticate_user!(with: :login, return_to: true, **options)
14
+ before_action -> { authenticate_user!(with: with, return_to: return_to) }, **options
15
+ end
16
+ end
17
+
12
18
  # Returns a boolean whether the user is signed in or not
13
19
  def user_signed_in?
14
20
  !!current_user
@@ -21,8 +27,11 @@ module ReviseAuth
21
27
  end
22
28
 
23
29
  # Authenticates a user or redirects to the login page
24
- def authenticate_user!
25
- redirect_to_login_with_stashed_location unless user_signed_in?
30
+ def authenticate_user!(with: :login, return_to: true)
31
+ return if user_signed_in?
32
+ stash_return_to_location(request.fullpath) if return_to && request.get?
33
+ path = (with == :sign_up) ? sign_up_path : login_path
34
+ redirect_to path, alert: t("revise_auth.sign_up_or_login")
26
35
  end
27
36
 
28
37
  def require_unauthenticated
@@ -69,11 +78,6 @@ module ReviseAuth
69
78
  session.delete(:user_return_to)
70
79
  end
71
80
 
72
- def redirect_to_login_with_stashed_location
73
- stash_return_to_location(request.fullpath) if request.get?
74
- redirect_to login_path, alert: t("revise_auth.sign_up_or_login")
75
- end
76
-
77
81
  def resolve_after_register_path
78
82
  try(:after_register_path) || return_to_location || root_path
79
83
  end
@@ -1,3 +1,3 @@
1
1
  module ReviseAuth
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.1"
3
3
  end
data/lib/revise_auth.rb CHANGED
@@ -1,10 +1,11 @@
1
+ require "active_support"
2
+ require "active_support/core_ext"
3
+
1
4
  require "revise_auth/version"
2
5
  require "revise_auth/engine"
3
6
  require "revise_auth/routes"
4
7
 
5
8
  module ReviseAuth
6
- include ActiveSupport::Configurable
7
-
8
9
  autoload :Authentication, "revise_auth/authentication"
9
10
  autoload :Current, "revise_auth/current"
10
11
  autoload :Model, "revise_auth/model"
@@ -14,8 +15,12 @@ module ReviseAuth
14
15
  autoload :Helpers, "revise_auth/test/helpers"
15
16
  end
16
17
 
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
20
- config_accessor :login_rate_limit, default: {to: 10, within: 3.minutes, only: :create}
18
+ def self.configure
19
+ yield self
20
+ end
21
+
22
+ mattr_accessor :sign_up_params, default: [:email, :password, :password_confirmation]
23
+ mattr_accessor :update_params, default: []
24
+ mattr_accessor :minimum_password_length, default: 12
25
+ mattr_accessor :login_rate_limit, default: {to: 10, within: 3.minutes, only: :create}
21
26
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revise_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-27 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -94,7 +93,6 @@ metadata:
94
93
  homepage_uri: https://github.com/excid3/revise_auth
95
94
  source_code_uri: https://github.com/excid3/revise_auth
96
95
  changelog_uri: https://github.com/excid3/revise_auth/blob/main/CHANGELOG.md
97
- post_install_message:
98
96
  rdoc_options: []
99
97
  require_paths:
100
98
  - lib
@@ -109,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
107
  - !ruby/object:Gem::Version
110
108
  version: '0'
111
109
  requirements: []
112
- rubygems_version: 3.5.14
113
- signing_key:
110
+ rubygems_version: 4.0.11
114
111
  specification_version: 4
115
112
  summary: Simple authentication for Ruby on Rails apps
116
113
  test_files: []