authentication-zero 2.2.1 → 2.2.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -7
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt +8 -1
- data/lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt +2 -2
- data/lib/generators/authentication/templates/erb/emails/edit.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/sessions/index.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/system/emails_test.rb.tt +2 -2
- data/lib/generators/authentication/templates/test_unit/system/registrations_test.rb.tt +1 -1
- data/lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ec32db1ac920db94f1c2350fbf5a98efeca35af8fa8ca1b4f83f1c93190753c
|
4
|
+
data.tar.gz: 196b5398bfccab4033f1d9b59897b5afcf2610449b9550e81f008b7c7145fa8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a551abfb08274802e4422117c5ac30200843bf66a6ee0fcfe6f2fa8dae8ae3e33bdf9d9304af7a60d74d2f3ae3e1a35b76f1988a55a7beaf36dcb53bfec8a0bd
|
7
|
+
data.tar.gz: 0ea020f80489a0c5d6e767754543b455b7e986c332fcd8ffea64a38b9f1000629cbb7cb40090c38cd789908d4c6c6590666b295ac9131b86a935f2f48d999195
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,16 +4,17 @@ The purpose of authentication zero is to generate a pre-built authentication sys
|
|
4
4
|
|
5
5
|
## Features
|
6
6
|
|
7
|
-
- **Simplest code ever**
|
7
|
+
- **Simplest code ever (~200 lines of code)**
|
8
|
+
- **Inspired by hey.com**
|
8
9
|
- Sign up
|
9
10
|
- Email and password validations
|
10
11
|
- Reset the user password and send reset instructions
|
11
12
|
- Reset the user password only from verified emails
|
12
13
|
- Authentication by cookie (html)
|
13
14
|
- Authentication by token (api)
|
14
|
-
- Send e-mail verification when
|
15
|
-
- Send e-mail when
|
16
|
-
- Manage multiple sessions
|
15
|
+
- Send e-mail verification when your email is changed
|
16
|
+
- Send e-mail when someone has signed-in into your account
|
17
|
+
- Manage multiple sessions & devices
|
17
18
|
- Cancel my account
|
18
19
|
- Log out
|
19
20
|
|
@@ -61,17 +62,19 @@ Add these lines to your `app/views/home/index.html.erb`:
|
|
61
62
|
</div>
|
62
63
|
|
63
64
|
<div>
|
64
|
-
<%= link_to "Change email", edit_email_path %>
|
65
|
+
<%= link_to "Change email address", edit_email_path %>
|
65
66
|
</div>
|
66
67
|
|
67
68
|
<div>
|
68
|
-
<%= link_to "
|
69
|
+
<%= link_to "Devices & Sessions", sessions_path %>
|
69
70
|
</div>
|
70
71
|
|
71
72
|
<div>
|
72
|
-
<%= button_to "Cancel my account", registration_path, method: :delete %>
|
73
|
+
<%= button_to "Cancel my account & delete my data", registration_path, method: :delete %>
|
73
74
|
</div>
|
74
75
|
|
76
|
+
<br>
|
77
|
+
|
75
78
|
<%= button_to "Log out", Current.session, method: :delete %>
|
76
79
|
```
|
77
80
|
|
data/lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
CHANGED
@@ -9,7 +9,10 @@ class RegistrationsController < ApplicationController
|
|
9
9
|
@<%= singular_table_name %> = <%= class_name %>.new(<%= "#{singular_table_name}_params" %>)
|
10
10
|
|
11
11
|
if @<%= singular_table_name %>.save
|
12
|
-
|
12
|
+
session = @<%= singular_table_name %>.sessions.create!(session_params)
|
13
|
+
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
14
|
+
|
15
|
+
redirect_to root_path, notice: "Welcome! You have signed up successfully"
|
13
16
|
else
|
14
17
|
render :new, status: :unprocessable_entity
|
15
18
|
end
|
@@ -24,4 +27,8 @@ class RegistrationsController < ApplicationController
|
|
24
27
|
def <%= "#{singular_table_name}_params" %>
|
25
28
|
params.require(:<%= singular_table_name %>).permit(:email, :password, :password_confirmation)
|
26
29
|
end
|
30
|
+
|
31
|
+
def session_params
|
32
|
+
{ user_agent: request.user_agent, ip_address: request.remote_ip }
|
33
|
+
end
|
27
34
|
end
|
@@ -15,8 +15,8 @@ class SessionsController < ApplicationController
|
|
15
15
|
@<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email])
|
16
16
|
|
17
17
|
if @<%= singular_table_name %>.try(:authenticate, params[:password])
|
18
|
-
|
19
|
-
cookies.signed.permanent[:session_token] = { value:
|
18
|
+
session = @<%= singular_table_name %>.sessions.create!(session_params)
|
19
|
+
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
20
20
|
|
21
21
|
redirect_to root_path, notice: "Signed in successfully"
|
22
22
|
else
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%% if Current.<%= singular_table_name %>.verified? %>
|
4
4
|
<h1>Change your email</h1>
|
5
5
|
<%% else %>
|
6
|
-
<h1>Verify your email
|
6
|
+
<h1>Verify your email</h1>
|
7
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
8
|
<p><%%= button_to "Re-send verification email", email_verification_path %></p>
|
9
9
|
<%% end %>
|
@@ -11,7 +11,7 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
|
|
11
11
|
post sign_up_url, params: { <%= singular_table_name %>: { email: "lazaronixon@hey.com", password: "secret123", password_confirmation: "secret123" } }
|
12
12
|
end
|
13
13
|
|
14
|
-
assert_redirected_to
|
14
|
+
assert_redirected_to root_url
|
15
15
|
end
|
16
16
|
|
17
17
|
test "should destroy account" do
|
@@ -6,7 +6,7 @@ class EmailsTest < ApplicationSystemTestCase
|
|
6
6
|
end
|
7
7
|
|
8
8
|
test "updating the email" do
|
9
|
-
click_on "Change email"
|
9
|
+
click_on "Change email address"
|
10
10
|
|
11
11
|
fill_in "Current password", with: "secret123"
|
12
12
|
fill_in "New email", with: "new_email@hey.com"
|
@@ -18,7 +18,7 @@ class EmailsTest < ApplicationSystemTestCase
|
|
18
18
|
test "sending a verification email" do
|
19
19
|
@<%= singular_table_name %>.update! verified: false
|
20
20
|
|
21
|
-
click_on "Change email"
|
21
|
+
click_on "Change email address"
|
22
22
|
click_on "Re-send verification email"
|
23
23
|
|
24
24
|
assert_text "We sent a verification email to your email address"
|
@@ -19,7 +19,7 @@ class RegistrationsTest < ApplicationSystemTestCase
|
|
19
19
|
|
20
20
|
test "cancelling my account" do
|
21
21
|
sign_in_as @<%= singular_table_name %>
|
22
|
-
click_on "Cancel my account"
|
22
|
+
click_on "Cancel my account & delete my data"
|
23
23
|
|
24
24
|
assert_text "Your account is closed"
|
25
25
|
end
|