revise_auth-jets 0.2.5 → 0.2.7
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 +7 -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: fceddb9d1ec0d9065d2194725c35563237a49b88bfd85e342da7b831eb3f9c7b
|
4
|
+
data.tar.gz: 755bdc5fa10f0a4964ab2fa9b647db0044024c1c1960412c70981cf9a6a5d0b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106b09568bc43803da2c92acf3c6b184e32966ca1fb25960e51282b3f3da9a07fc391eda3fc5942e384ea7985938b2b3d437a146c6e511cb9ab7b1e89f3dd7e7
|
7
|
+
data.tar.gz: 84eb4d467d5cb600b5395df5bbe014330f3a16e31cd510071c16fd9f4e8c394e14b83af5b295981ed4f8f36eed0acbd6c2c2185f44f1303019658dda21b2b90b
|
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,10 @@ 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
|
-
|
29
|
+
token = generate_token_for
|
30
|
+
self.confirmation_token = token
|
31
|
+
self.save!
|
32
|
+
ReviseAuth::Mailer.with(user: self.unconfirmed_email, token: token).confirm_email.deliver_later
|
31
33
|
end
|
32
34
|
|
33
35
|
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.7
|
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
|