revise_auth-jets 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -1
- data/app/controllers/revise_auth/email_controller.rb +1 -1
- data/app/mailers/revise_auth/mailer.rb +2 -1
- data/app/views/revise_auth/mailer/confirm_email.html.erb +2 -2
- data/lib/generators/revise_auth/templates/README +2 -0
- data/lib/revise_auth/model.rb +5 -5
- data/lib/revise_auth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b96f19ca673fce3a68511610228f5c1d278e50876356bee4879fdd7a88415da
|
4
|
+
data.tar.gz: 81a273963a87ba0877d6f05a3dff750335502bdecd26d2ec776ddb90477f6d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6bb295d947a7379f09bd351c189597ffe328ee963f5e4f31ac339e264e7f3b70f77ea0a7bfae947659b47fb364b82ce5069bfc3501e89ec0c532703a2d95ddc
|
7
|
+
data.tar.gz: 0dcb43412aa5c16aec8dd2a93204ec67592034919fd1b901d041b98724c34e36391eb2b72c5f5d45f9b6e3c11ef4bd7ae6df493452c68fd560437e28d8b339d3
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ A pure Ruby on Jets authentication system like Devise.
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
bundle add "revise_auth"
|
10
|
+
bundle add "revise_auth-jets"
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute the following to generate a `User` model (optionally adding other fields such as `first_name` and `last_name`):
|
@@ -17,6 +17,45 @@ $ jets db:migrate
|
|
17
17
|
$ jets g revise_auth:views
|
18
18
|
```
|
19
19
|
|
20
|
+
Add ActiveRecord::Base.signed_id_verifier_secret = "custom_verfifier_secret" in your initializers. Set this as an env var
|
21
|
+
|
22
|
+
|
23
|
+
Create your app/mailer/application_mailer.rb
|
24
|
+
|
25
|
+
```
|
26
|
+
class ApplicationMailer < ActionMailer::Base
|
27
|
+
default from: 'YOUR_EMAIL@gmail.com'
|
28
|
+
layout 'mailer'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
|
33
|
+
Add your stmp settings in your development.rb
|
34
|
+
ex:
|
35
|
+
```
|
36
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000, protocol: "https" }
|
37
|
+
config.action_mailer.perform_deliveries = true
|
38
|
+
config.action_mailer.show_previews = true
|
39
|
+
config.action_mailer.delivery_method = :smtp
|
40
|
+
config.action_mailer.smtp_settings = {
|
41
|
+
address: 'smtp.gmail.com',
|
42
|
+
port: 587,
|
43
|
+
domain: 'gmail.com',
|
44
|
+
user_name: 'USERNAME@gmail.com',
|
45
|
+
password: 'YOUR_PASS',
|
46
|
+
authentication: 'plain'}
|
47
|
+
```
|
48
|
+
To get your stmp pass follow these steps
|
49
|
+
|
50
|
+
You need to make a password for specific app
|
51
|
+
|
52
|
+
Step one: enable 2FA
|
53
|
+
|
54
|
+
https://myaccount.google.com/signinoptions/two-step-verification/enroll-welcome
|
55
|
+
Step two: create an app-specific password
|
56
|
+
|
57
|
+
https://myaccount.google.com/apppasswords
|
58
|
+
|
20
59
|
## Usage
|
21
60
|
|
22
61
|
ReviseAuth is designed around a single `User` model.
|
@@ -3,7 +3,7 @@ class ReviseAuth::EmailController < ReviseAuthController
|
|
3
3
|
|
4
4
|
# GET /profile/email?confirmation_token=abcdef
|
5
5
|
def show
|
6
|
-
if User.
|
6
|
+
if User.find_signed(params[:confirmation_token], purpose: :email_verification)&.confirm_email_change
|
7
7
|
#flash[:notice] = I18n.t("revise_auth.email_confirmed")
|
8
8
|
redirect_to(user_signed_in? ? profile_path : root_path)
|
9
9
|
else
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<p>Welcome <%= @user
|
1
|
+
<p>Welcome <%= @user %>!</p>
|
2
2
|
|
3
3
|
<p>You can confirm your account email through the link below:</p>
|
4
4
|
|
5
|
-
<
|
5
|
+
<a href="<%= profile_email_url() + @url %>">Confirm my account</a>
|
6
6
|
|
7
7
|
<p>This link will expire in 24 hours.</p>
|
@@ -3,4 +3,6 @@
|
|
3
3
|
Next step:
|
4
4
|
Add "add_index :users, :email, unique: true" at the bottom of the change method
|
5
5
|
Run "jets db:migrate"
|
6
|
+
Add ActiveRecord::Base.signed_id_verifier_secret = "custom_verfifier_secret" in your initializers/ Set this as an env var
|
7
|
+
Add your stmp settings in your development.rb
|
6
8
|
Run "jets g revise_auth:views"
|
data/lib/revise_auth/model.rb
CHANGED
@@ -10,9 +10,9 @@ module ReviseAuth
|
|
10
10
|
has_secure_password
|
11
11
|
has_secure_token :confirmation_token
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def generate_token_for
|
14
|
+
signed_id expires_in: EMAIL_VERIFICATION_TOKEN_VALIDITY, purpose: :email_verification
|
15
|
+
end
|
16
16
|
|
17
17
|
validates :email, format: {with: URI::MailTo::EMAIL_REGEXP}, presence: true, uniqueness: true
|
18
18
|
validates :unconfirmed_email, format: {with: URI::MailTo::EMAIL_REGEXP}, allow_blank: true
|
@@ -26,8 +26,8 @@ module ReviseAuth
|
|
26
26
|
|
27
27
|
# Generates a confirmation token and send email to the user
|
28
28
|
def send_confirmation_instructions
|
29
|
-
token = generate_token_for
|
30
|
-
ReviseAuth::Mailer.with(user: self, token: token).confirm_email.deliver_later
|
29
|
+
token = generate_token_for
|
30
|
+
ReviseAuth::Mailer.with(user: self.unconfirmed_email, token: token).confirm_email.deliver_later
|
31
31
|
end
|
32
32
|
|
33
33
|
def confirm_email_change
|
data/lib/revise_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revise_auth-jets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremiah Parrack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|