action_auth 0.1.2 → 0.1.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
  SHA256:
3
- metadata.gz: 3745646b8654c9678ab57b1539e7190f3c002f3352dda31cf06a884604f2dfdd
4
- data.tar.gz: 92f62b3fd0607982f545408db8196f6b24ba43b63df5b166f0262daa77a00013
3
+ metadata.gz: d680d8d34330e5aec31d3ab30576b677f4b3320c9cb9383b0a2ea2d5369c4541
4
+ data.tar.gz: 6c5d816b40895ec52e7b6ec331127263e5e82a80b6e838a6fd1e047366de1ea5
5
5
  SHA512:
6
- metadata.gz: f422203f6efa8a50d9de3140b0f97ad6eabe7a2d17bf79d36d352e41a08a20fe0bd23ab3f4587563655a2fb52ffc0800d5d1a783f97161a5b773d1df4647c751
7
- data.tar.gz: 618b27e2c259afcd7018595087fa10cb828d38dee863b3d76f67dfff2f2e37e086bc6c240494769990265130831cd839c46c6edaf43a0c6051c4f58b2f852d4f
6
+ metadata.gz: 19e8c186624ccf06148d16932b6026143560479594d07e2bed4298f4c18b83df65a17e1ee88149c7fc6a9b0a1b1afbebc4a95023cebee81d15d393bbe984f6c1
7
+ data.tar.gz: 27e0a47e5cc73e646bacb873610a514211fc0bbd471d38776da5af2f419a73d85da135998a452a041e0ae3871fb4cec983204297923b274b98b6cd80fa256c36
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ActionAuth
2
- This is a placeholder for the ActionAuth gem. It is not yet ready for use.
2
+ ActionAuth is a Rails engine that provides a simple authentication system for your Rails application.
3
+ It uses the latest methods for authentication and handling reset tokens from Rails 7.1.0.
4
+ It is designed to be simple and easy to use and allows you to focus on building your application.
5
+ The functionality of this gem relies on ActiveSupport::CurrentAttributes the methods are
6
+ designed to have a similar experience as Devise.
3
7
 
4
8
  ## Installation
5
9
  Add this line to your application's Gemfile:
@@ -15,6 +19,18 @@ Modify config/routes.rb to include the following:
15
19
  mount ActionAuth::Engine => 'action_auth'
16
20
  ```
17
21
 
22
+ In your view layout
23
+
24
+ ```ruby
25
+ <% if user_signed_in? %>
26
+ <li><%= link_to "Sessions", user_sessions_path %></li>
27
+ <li><%= button_to "Sign Out", user_session_path(current_session), method: :delete %></li>
28
+ <% else %>
29
+ <li><%= link_to "Sign In", new_user_session_path %></li>
30
+ <li><%= link_to "Sign Up", new_user_registration_path %></li>
31
+ <% end %>
32
+ ```
33
+
18
34
  ## Usage
19
35
 
20
36
  ### Routes
@@ -22,18 +38,19 @@ mount ActionAuth::Engine => 'action_auth'
22
38
  Within your application, you'll have access to these routes. They have been styled to be consistent with Devise.
23
39
 
24
40
  Method Verb Params Description
25
- user_sessions_path GET Device session management
26
- user_session_path DELETE [:id] Log Out
27
- new_user_session_path GET Log in
28
- new_user_registration_path GET Sign Up
41
+ user_sessions_path GET Device session management
42
+ user_session_path DELETE [:id] Log Out
43
+ new_user_session_path GET Log in
44
+ new_user_registration_path GET Sign Up
45
+ edit_password_path GET Change Password
46
+ password_path PATCH Update Password
29
47
 
30
48
  ### Helper Methods
31
49
 
32
50
  Method Description
33
- current_user Returns the currently logged in user
51
+ current_user Returns the currently logged in user
34
52
  user_signed_in? Returns true if the user is logged in
35
- current_session Returns the current session
36
-
53
+ current_session Returns the current session
37
54
 
38
55
  ## License
39
56
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,15 +1,101 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
1
+ body {
2
+ box-sizing: border-box;
3
+ margin: 0;
4
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
5
+ font-size: 1rem;
6
+ font-weight: 400;
7
+ line-height: 1.5;
8
+ color: #212529;
9
+ text-align: left;
10
+ /* Assuming default alignment should be left */
11
+ -webkit-text-size-adjust: 100%;
12
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
13
+ margin-top: 25px;
14
+ background-color: rgb(248, 249, 250) !important;
15
+ }
16
+
17
+ .container {
18
+ -webkit-text-size-adjust: 100%;
19
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
20
+ box-sizing: border-box;
21
+ width: 400px;
22
+ padding-right: 12px;
23
+ padding-left: 12px;
24
+ margin-right: auto;
25
+ margin-left: auto;
26
+ max-width: 1140px;
27
+ border: solid 1px rgb(222, 226, 230) !important;
28
+ padding-bottom: 1rem !important;
29
+ background-color: rgb(255, 255, 255) !important;
30
+ }
31
+
32
+ input[type="text"],
33
+ input[type="email"],
34
+ input[type="password"] {
35
+ -webkit-text-size-adjust: 100%;
36
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
37
+ box-sizing: border-box;
38
+ margin: 0;
39
+ font-family: inherit;
40
+ display: block;
41
+ width: 100%;
42
+ padding: 0.375rem 0.75rem;
43
+ font-size: 1rem;
44
+ font-weight: 400;
45
+ line-height: 1.5;
46
+ color: #212529;
47
+ appearance: none;
48
+ background-color: #fff;
49
+ background-clip: padding-box;
50
+ border: 1px solid #dee2e6;
51
+ border-radius: 0.375rem;
52
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
53
+ }
54
+
55
+ .mb-3 {
56
+ margin-bottom: 1rem !important;
57
+ }
58
+
59
+ .btn {
60
+ padding: 0.375rem 0.75rem;
61
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
62
+ font-size: 1rem;
63
+ font-weight: 400;
64
+ line-height: 1.5;
65
+ color: #333;
66
+ text-align: center;
67
+ text-decoration: none;
68
+ vertical-align: middle;
69
+ user-select: none;
70
+ border: 1px solid #007bff;
71
+ border-radius: 0.25rem;
72
+ background-color: #007bff;
73
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 0, 0, 0.075);
74
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
75
+ cursor: pointer;
76
+ }
77
+
78
+ .btn:hover {
79
+ color: #fff;
80
+ background-color: #0056b3;
81
+ border-color: #004085;
82
+ }
83
+
84
+ .btn:focus {
85
+ outline: 0;
86
+ box-shadow: 0 0 0 0.25rem rgba(49, 132, 253, .5);
87
+ }
88
+
89
+ .btn:disabled {
90
+ color: #fff;
91
+ background-color: #007bff;
92
+ border-color: #007bff;
93
+ opacity: 0.65;
94
+ pointer-events: none;
95
+ }
96
+
97
+ .btn-primary {
98
+ color: #fff;
99
+ background-color: #007bff;
100
+ border-color: #007bff;
101
+ }
@@ -22,6 +22,7 @@ module ActionAuth
22
22
  end
23
23
 
24
24
  def send_email_verification
25
+ return unless Current.user
25
26
  UserMailer.with(user: Current.user).email_verification.deliver_later
26
27
  end
27
28
  end
@@ -1,18 +1,21 @@
1
- <p style="color: red"><%= alert %></p>
2
1
 
3
- <% if ActionAuth::Current.user.verified? %>
4
- <h1>Change your email</h1>
2
+ <% if user_signed_in? && Current.user.verified? %>
3
+ <% header_text = "Change Your Email" %>
4
+ <% label_text = "New email" %>
5
+ <% button_text = "Save changes" %>
5
6
  <% else %>
6
- <h1>Verify your email</h1>
7
- <p>We sent a verification email to the address below. Check that email and follow those instructions to confirm it's your email address.</p>
8
- <p><%= button_to "Re-send verification email", identity_email_verification_path %></p>
7
+ <% header_text = "Verify Your Email" %>
8
+ <% label_text = "Email" %>
9
+ <% button_text = "Send verification email" %>
9
10
  <% end %>
11
+ <h1><%= header_text %></h1>
12
+
13
+ <p style="color: red"><%= alert %></p>
10
14
 
11
15
  <%= form_with(url: identity_email_path, method: :patch) do |form| %>
12
- <% if @user.errors.any? %>
16
+ <% if @user&.errors&.any? %>
13
17
  <div style="color: red">
14
18
  <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
15
-
16
19
  <ul>
17
20
  <% @user.errors.each do |error| %>
18
21
  <li><%= error.full_message %></li>
@@ -21,23 +24,23 @@
21
24
  </div>
22
25
  <% end %>
23
26
 
24
- <div>
25
- <%= form.label :email, "New email", style: "display: block" %>
27
+ <div class="mb-3">
28
+ <%= form.label :email, label_text, style: "display: block" %>
26
29
  <%= form.email_field :email, required: true, autofocus: true %>
27
30
  </div>
28
31
 
29
- <div>
30
- <%= form.label :password_challenge, style: "display: block" %>
31
- <%= form.password_field :password_challenge, required: true, autocomplete: "current-password" %>
32
- </div>
32
+ <div class="mb-3">
33
+ <% if user_signed_in? && Current.user.verified? %>
34
+ <%= form.submit button_text, class: "btn btn-primary" %>
35
+ <% else %>
36
+ <%= button_to button_text, identity_email_verification_path, class: "btn btn-primary" %>
37
+ <% end %>
33
38
 
34
- <div>
35
- <%= form.submit "Save changes" %>
36
39
  </div>
37
40
  <% end %>
38
41
 
39
- <br>
40
-
41
- <div>
42
- <%= link_to "Back", main_app.root_path %>
42
+ <div class="mb-3">
43
+ <%= link_to "Sign In", sign_in_path %> |
44
+ <%= link_to "Sign Up", sign_up_path %> |
45
+ <%= link_to "Reset Password", new_identity_password_reset_path %>
43
46
  </div>
@@ -1,14 +1,19 @@
1
- <p style="color: red"><%= alert %></p>
2
-
3
1
  <h1>Forgot your password?</h1>
2
+ <p style="color: red"><%= alert %></p>
4
3
 
5
4
  <%= form_with(url: identity_password_reset_path) do |form| %>
6
- <div>
5
+ <div class="mb-3">
7
6
  <%= form.label :email, style: "display: block" %>
8
7
  <%= form.email_field :email, required: true, autofocus: true %>
9
8
  </div>
10
9
 
11
- <div>
12
- <%= form.submit "Send password reset email" %>
10
+ <div class="mb-3">
11
+ <%= form.submit "Send password reset email", class: "btn btn-primary" %>
13
12
  </div>
14
13
  <% end %>
14
+
15
+ <div class="mb-3">
16
+ <%= link_to "Sign In", sign_in_path %> |
17
+ <%= link_to "Sign Up", sign_up_path %> |
18
+ <%= link_to "Verify Email", identity_email_verification_path %>
19
+ </div>
@@ -13,23 +13,29 @@
13
13
  </div>
14
14
  <% end %>
15
15
 
16
- <div>
16
+ <div class="mb-3">
17
17
  <%= form.label :email, style: "display: block" %>
18
18
  <%= form.email_field :email, value: @user.email, required: true, autofocus: true, autocomplete: "email" %>
19
19
  </div>
20
20
 
21
- <div>
21
+ <div class="mb-3">
22
22
  <%= form.label :password, style: "display: block" %>
23
23
  <%= form.password_field :password, required: true, autocomplete: "new-password" %>
24
24
  <div>12 characters minimum.</div>
25
25
  </div>
26
26
 
27
- <div>
27
+ <div class="mb-3">
28
28
  <%= form.label :password_confirmation, style: "display: block" %>
29
29
  <%= form.password_field :password_confirmation, required: true, autocomplete: "new-password" %>
30
30
  </div>
31
31
 
32
- <div>
33
- <%= form.submit "Sign up" %>
32
+ <div class="mb-3">
33
+ <%= form.submit "Sign up", class: "btn btn-primary" %>
34
34
  </div>
35
35
  <% end %>
36
+
37
+ <div class="mb-3">
38
+ <%= link_to "Sign In", sign_in_path %> |
39
+ <%= link_to "Reset Password", new_identity_password_reset_path %> |
40
+ <%= link_to "Verify Email", identity_email_verification_path %>
41
+ </div>
@@ -4,27 +4,23 @@
4
4
  <h1>Sign in</h1>
5
5
 
6
6
  <%= form_with(url: sign_in_path) do |form| %>
7
- <div>
7
+ <div class="mb-3">
8
8
  <%= form.label :email, style: "display: block" %>
9
9
  <%= form.email_field :email, value: params[:email_hint], required: true, autofocus: true, autocomplete: "email" %>
10
10
  </div>
11
11
 
12
- <div>
12
+ <div class="mb-3">
13
13
  <%= form.label :password, style: "display: block" %>
14
14
  <%= form.password_field :password, required: true, autocomplete: "current-password" %>
15
15
  </div>
16
16
 
17
- <div>
18
- <%= form.submit "Sign in" %>
17
+ <div class="mb-3">
18
+ <%= form.submit "Sign in", class: "btn btn-primary" %>
19
19
  </div>
20
20
  <% end %>
21
21
 
22
- <br>
23
-
24
-
25
- <br>
26
-
27
- <div>
28
- <%= link_to "Sign up", sign_up_path %> |
29
- <%# link_to "Forgot your password?", new_identity_password_reset_path %>
22
+ <div class="mb-3">
23
+ <%= link_to "Sign Up", sign_up_path %> |
24
+ <%= link_to "Reset Password", new_identity_password_reset_path %> |
25
+ <%= link_to "Verify Email", identity_email_verification_path %>
30
26
  </div>
@@ -7,9 +7,9 @@
7
7
 
8
8
  <%= stylesheet_link_tag "action_auth/application", media: "all" %>
9
9
  </head>
10
- <body>
11
-
12
- <%= yield %>
13
-
10
+ <body class="bg-light">
11
+ <div class="container bg-white border pb-3">
12
+ <%= yield %>
13
+ </div>
14
14
  </body>
15
15
  </html>
@@ -1,3 +1,3 @@
1
1
  module ActionAuth
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura