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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6227cbb54b0253065b69a653c7303d0facaecfead734d096e115dbfd265723a
4
- data.tar.gz: b380ea36c938fddb60bec59749ee1cd83f49dea5ef7125f73d079a359b55525a
3
+ metadata.gz: 5b96f19ca673fce3a68511610228f5c1d278e50876356bee4879fdd7a88415da
4
+ data.tar.gz: 81a273963a87ba0877d6f05a3dff750335502bdecd26d2ec776ddb90477f6d3f
5
5
  SHA512:
6
- metadata.gz: cec91fa6a28b8ccc457318b211574673b2b1782c52066386939e42665926d7e3505db1f29e1967e789b552acc4205ba36ef7ea69dbb6cec5ebcc01ba081488f3
7
- data.tar.gz: ca581e3d7cae6e3acfbbd98f518dc8b18d521b78b6a7c0b40c418fad4509f833f903425467e9a6879b4bf5992fccb8e8670d74e03ada484d291772355d6f2816
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.find_by_token_for(:email_verification, params[:confirmation_token])&.confirm_email_change
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
@@ -2,7 +2,8 @@ class ReviseAuth::Mailer < ApplicationMailer
2
2
  def confirm_email
3
3
  @user = params[:user]
4
4
  @token = params[:token]
5
+ @url = "?confirmation_token=" + @token
5
6
 
6
- mail to: @user.unconfirmed_email
7
+ mail to: @user
7
8
  end
8
9
  end
@@ -1,7 +1,7 @@
1
- <p>Welcome <%= @user.unconfirmed_email %>!</p>
1
+ <p>Welcome <%= @user %>!</p>
2
2
 
3
3
  <p>You can confirm your account email through the link below:</p>
4
4
 
5
- <p><%= link_to "Confirm my account", profile_email_url(confirmation_token: @token) %></p>
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"
@@ -10,9 +10,9 @@ module ReviseAuth
10
10
  has_secure_password
11
11
  has_secure_token :confirmation_token
12
12
 
13
- # generates_token_for :email_verification, expires_in: EMAIL_VERIFICATION_TOKEN_VALIDITY do
14
- # email
15
- # end
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(:email_verification)
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
@@ -1,3 +1,3 @@
1
1
  module ReviseAuth
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
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.5
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-13 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt