authentication-zero 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- 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/test_unit/controllers/html/registrations_controller_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: ebc9ddc7618fcddba8022355329e17c9c2c57cef7a0fc01841f9a81a2aa2d02f
|
4
|
+
data.tar.gz: 3c3c7f689a728dd430619b20e9436576e70bae5b8d0eb7846d604101cbe14de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8d013ce1b98fc3103c3259de61a12550b4c54628f2d246bd45fbd90d464322869330c3d8ade099600a87aa58f10f4fa02d289ca3a71db4772f4242d2ee2933
|
7
|
+
data.tar.gz: 464a5dad30c894bf3a3b5db0637589efff8b7cfbfe41190c4b40826365529f617c3b7e7ed977fef85294a133107445f3d4e35e0a3aea84882a548f1f85bd8502
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,16 +4,16 @@ 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
8
|
- Sign up
|
9
9
|
- Email and password validations
|
10
10
|
- Reset the user password and send reset instructions
|
11
11
|
- Reset the user password only from verified emails
|
12
12
|
- Authentication by cookie (html)
|
13
13
|
- Authentication by token (api)
|
14
|
-
- Send e-mail verification when
|
15
|
-
- Send e-mail when
|
16
|
-
- Manage multiple sessions
|
14
|
+
- Send e-mail verification when your email is changed
|
15
|
+
- Send e-mail when someone has signed-in into your account
|
16
|
+
- Manage multiple sessions & devices
|
17
17
|
- Cancel my account
|
18
18
|
- Log out
|
19
19
|
|
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
|
@@ -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
|