revise_auth-jets 0.2.4 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7a1ffd203ee63755e312b3e2935e3b9bc37cd0ffe4c440b89312dd03dc4011c
4
- data.tar.gz: 26151a499447020789c443d358926790686d2c48e841eb8dd6d5fb989c42c4de
3
+ metadata.gz: 5b96f19ca673fce3a68511610228f5c1d278e50876356bee4879fdd7a88415da
4
+ data.tar.gz: 81a273963a87ba0877d6f05a3dff750335502bdecd26d2ec776ddb90477f6d3f
5
5
  SHA512:
6
- metadata.gz: 714ca45cac1021f445084b24a2719c4ff2981378c85151a22096220e3e67430f514ced871372ad12c49bef9f225509f844f0f71566fbaca992604159d9a75355
7
- data.tar.gz: d6b6a4d59eb5ccb545adbc8b419af6d30c00081d92efa5af8cbca439e4eaa540232e432d982bb3364c1e146585b1a815ba65283c7f8794e7df35022be7b5f772
6
+ metadata.gz: f6bb295d947a7379f09bd351c189597ffe328ee963f5e4f31ac339e264e7f3b70f77ea0a7bfae947659b47fb364b82ce5069bfc3501e89ec0c532703a2d95ddc
7
+ data.tar.gz: 0dcb43412aa5c16aec8dd2a93204ec67592034919fd1b901d041b98724c34e36391eb2b72c5f5d45f9b6e3c11ef4bd7ae6df493452c68fd560437e28d8b339d3
data/README.md CHANGED
@@ -7,16 +7,55 @@ 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`):
14
14
  ```bash
15
- $ jetsg revise_auth:model User first_name last_name
15
+ $ jets g revise_auth:model User first_name last_name
16
16
  $ jets db:migrate
17
- $ jetsg revise_auth:views
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
@@ -1,4 +1,4 @@
1
- require 'revise_auth'
1
+ require 'revise_auth-jets'
2
2
  class ReviseAuthController < ApplicationController
3
3
  # Return true if it's a revise_auth_controller. false to all controllers unless
4
4
  # the controllers defined inside revise_auth. Useful if you want to apply a before
@@ -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.4"
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.4
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