avocado 0.3.0 → 0.4.0

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: '04228885896e7d922d727e6497a22a933f3910c96afad40b69bd21d209ab4a3c'
4
- data.tar.gz: 8a71cb118b5d97513f506d44ee5b2e01a0af5747d9e8151c9d866a589565d660
3
+ metadata.gz: e265345c4e35e1dd2caed0c61da1298f12767aac67bf9e87b92433d47866375b
4
+ data.tar.gz: 1253d00e053907caa9d78cd7f8667a695aae55853fbb6db94b45bbcd1845da10
5
5
  SHA512:
6
- metadata.gz: 6ff80323ec0979cbfecaa008f7cca93a73c7e2e82df4ac5590caae93de5b3b903c9fc724ab8508c50d70299d118df94718d6c22d00b0f990798a0a3544091a7f
7
- data.tar.gz: d39393b42cfc22511acecaceacce2dc345a65a1500fe3071c7b69f11876f479eb48d9d03beee052a0518b485da2ded599b6fe919454df7bb547a4e2d3ac67664
6
+ metadata.gz: 2fb300cf06c7c67fc9ecfea196bd23b770482f2b765d9438fb2ee24f193942565db6d470a75bce99bb1b016b94f355ab9e4b6f6a5a19bb0277d79c7bb06c247d
7
+ data.tar.gz: 9437dfe9000245f75089c3705a3bf4527705ceccab38a6760381d57dd13fda74881eb14db25b8ca33f26aee67fa6fd30ce42632a24541bcb1c672e6ea9eb80b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2023-07-19
4
+
5
+ - Convert the `Avocado::Mailer` module into a class
6
+ - Add controllers for signing up, signing in, password reset and email
7
+ verification
8
+
3
9
  ## [0.3.0] - 2023-07-17
4
10
 
5
11
  - Add an `Avocado::Mailer` which generates each of the signed ids
data/README.md CHANGED
@@ -4,42 +4,45 @@ A collection of authentication tools for use in [Rails] 7.1+ applications.
4
4
 
5
5
  ## Installation
6
6
 
7
- With bundler, add to the application's Gemfile by executing:
7
+ Add to the application's Gemfile by executing:
8
8
 
9
9
  $ bundle add avocado
10
10
 
11
- Without bundler, install the gem by executing:
11
+ ## Usage
12
12
 
13
- $ gem install avocado
13
+ If you are nervous about using Rails features directly, preferring to consume
14
+ such features via a packaged gem, you can include some Avocado modules into your
15
+ application to get authentication functionality.
14
16
 
15
- ## Usage
17
+ As a prerequisite, you should have a database schema with columns that match the
18
+ users and sessions tables from [the demo app schema]. It's ok to have more
19
+ columns, but you need at least what is shown there.
16
20
 
17
- If you have a `User` model in your application and are nervous about using Rails
18
- features directly, preferring to consume the features via a packaged gem, add
19
- the `Avocado::User` to your `User` model:
21
+ With that set, include the modules into your classes:
20
22
 
21
23
  ```ruby
22
24
  class User < ApplicationRecord
23
25
  include Avocado::User
24
26
  end
25
- ```
26
27
 
27
- This will do a few things behind the scenes:
28
+ class Session < ApplicationRecord
29
+ include Avocado::Session
30
+ end
28
31
 
29
- - Use the built-in `has_secure_password` to generate relevant password methods
30
- - Add some basic validations for the `email` and `password` fields on `User`
31
- - Normalize email values when records are saved
32
- - Provide signed token generators for `password_reset`, `email_verification`,
33
- and `email_affirmation`
32
+ class ApplicationController < ActionController::Base
33
+ include Avocado::Authentication
34
+ end
35
+ ```
34
36
 
35
- It's sort of funny to do this because you genuinely just could have put this
36
- stuff right in your app, and yet here we are making gems instead!
37
+ This will enable a few things:
37
38
 
38
- There is an `Avocado::Mailer` which can be included in a mailer class and
39
- provides some basic mailers.
39
+ - Models will get validations, associations, and normalizations
40
+ - Rails built-in `has_secure_password` is called within `User`
41
+ - A mailer with signed token generators is created
42
+ - Controllers and Routes for sign up, sign in, password reset, email
43
+ verification, etc
40
44
 
41
- The `spec/internal` app within this repo has some example usage of both model
42
- and mailer.
45
+ The `spec/internal` app within this repo has some example usage.
43
46
 
44
47
  ## Development
45
48
 
@@ -47,11 +50,6 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
47
50
  `rake spec` to run the tests. You can also run `bin/console` for an interactive
48
51
  prompt that will allow you to experiment.
49
52
 
50
- To install this gem onto your local machine, run `bundle exec rake install`. To
51
- release a new version, update the version number in `version.rb`, and then run
52
- `bundle exec rake release`, which will create a git tag for the version, push
53
- git commits and the created tag, and push the `.gem` file to [RubyGems].
54
-
55
53
  ## Contributing
56
54
 
57
55
  Bug reports and pull requests are welcome on [GitHub].
@@ -60,7 +58,7 @@ Bug reports and pull requests are welcome on [GitHub].
60
58
 
61
59
  The gem is available as open source under the terms of the [MIT License].
62
60
 
63
- [GitHub]: https://github.com/unicorngroomers/avocado
61
+ [GitHub]: https://github.com/tcuwp/avocado
64
62
  [MIT License]: https://opensource.org/licenses/MIT
65
63
  [Rails]: https://github.com/rails/rails
66
- [RubyGems]: https://rubygems.org
64
+ [the demo app schema]: https://github.com/tcuwp/avocado/blob/main/spec/internal/db/schema.rb
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ class BaseController < ApplicationController
5
+ private
6
+
7
+ def mailer_for(user)
8
+ Avocado::Mailer.with(user: user)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ class RecoveriesController < BaseController
5
+ PERMITTED_PARAMS = %i[password password_confirmation]
6
+
7
+ skip_before_action :authenticate
8
+
9
+ before_action :set_user, only: %i[edit update]
10
+ before_action :verify_user, only: :create
11
+
12
+ def new
13
+ end
14
+
15
+ def edit
16
+ end
17
+
18
+ def create
19
+ send_password_reset_email
20
+ redirect_to new_session_path, notice: "Check your email for reset instructions."
21
+ end
22
+
23
+ def update
24
+ if @user.update(user_params)
25
+ redirect_to new_session_path, notice: "Password reset successfully. Please sign in."
26
+ else
27
+ render :edit, status: :unprocessable_entity
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def set_user
34
+ @user = user_from_signed_password_reset_token
35
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
36
+ redirect_to new_recovery_path, alert: "Password reset link is invalid."
37
+ end
38
+
39
+ def user_from_signed_password_reset_token
40
+ ::User.find_by_token_for!(:password_reset, params[:id])
41
+ end
42
+
43
+ def verify_user
44
+ unless user_from_params_email
45
+ redirect_to new_recovery_path, alert: "Verify email first before resetting password."
46
+ end
47
+ end
48
+
49
+ def user_params
50
+ params
51
+ .require(:user)
52
+ .permit(PERMITTED_PARAMS)
53
+ end
54
+
55
+ def user_from_params_email
56
+ ::User.find_by(email: params[:email], verified: true)
57
+ end
58
+
59
+ def send_password_reset_email
60
+ mailer_for(user_from_params_email)
61
+ .password_reset
62
+ .deliver_later
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ class RegistrationsController < BaseController
5
+ PERMITTED_PARAMS = %i[email password password_confirmation]
6
+
7
+ skip_before_action :authenticate
8
+
9
+ def new
10
+ @user = ::User.new
11
+ end
12
+
13
+ def create
14
+ @user = ::User.new(user_params)
15
+
16
+ if @user.save
17
+ sign_in(@user)
18
+
19
+ send_email_verification
20
+ redirect_to root_path, notice: "Registration successful"
21
+ else
22
+ render :new, status: :unprocessable_entity
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def user_params
29
+ params
30
+ .require(:user)
31
+ .permit(PERMITTED_PARAMS)
32
+ end
33
+
34
+ def send_email_verification
35
+ mailer_for(@user)
36
+ .email_verification
37
+ .deliver_later
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ class SessionsController < BaseController
5
+ PERMITTED_PARAMS = %i[email password]
6
+
7
+ skip_before_action :authenticate, only: %i[new create]
8
+
9
+ with_options only: :create do
10
+ before_action :verify_authentication_attempt
11
+ end
12
+
13
+ before_action :set_session, only: :destroy
14
+
15
+ def index
16
+ @sessions = current_user.sessions.newest_first
17
+ end
18
+
19
+ def new
20
+ @session = ::Session.new
21
+ end
22
+
23
+ def create
24
+ sign_in(authenticated_user)
25
+
26
+ redirect_to root_path, notice: "Session created"
27
+ end
28
+
29
+ def destroy
30
+ @session.destroy
31
+ redirect_to sessions_path, notice: "Session destroyed"
32
+ end
33
+
34
+ private
35
+
36
+ def session_params
37
+ params
38
+ .require(:session)
39
+ .permit(PERMITTED_PARAMS)
40
+ .with_defaults(email: "", password: "")
41
+ end
42
+
43
+ def authenticated_user
44
+ @_authenticated_user ||= ::User.authenticate_by(session_params)
45
+ end
46
+
47
+ def verify_authentication_attempt
48
+ if authenticated_user.blank?
49
+ redirect_to new_session_path, alert: "Authentication failed"
50
+ end
51
+ end
52
+
53
+ def set_session
54
+ @session = current_user.sessions.find(params[:id])
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ class VerificationsController < BaseController
5
+ with_options only: :show do
6
+ skip_before_action :authenticate
7
+ before_action :set_user
8
+ end
9
+
10
+ def show
11
+ @user.update! verified: true
12
+ redirect_to root_path, notice: "Email address verified."
13
+ end
14
+
15
+ def create
16
+ send_email_verification
17
+ redirect_to root_path, notice: "Verification email sent to your address."
18
+ end
19
+
20
+ private
21
+
22
+ def set_user
23
+ @user = user_from_signed_email_verification_token
24
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
25
+ redirect_to root_path, alert: "Email verification link is invalid."
26
+ end
27
+
28
+ def user_from_signed_email_verification_token
29
+ ::User.find_by_token_for!(:email_verification, params[:id])
30
+ end
31
+
32
+ def send_email_verification
33
+ mailer_for(current_user)
34
+ .email_verification
35
+ .deliver_later
36
+ end
37
+ end
38
+ end
@@ -0,0 +1 @@
1
+ Email affirmation email
@@ -0,0 +1,3 @@
1
+ Email verification email
2
+
3
+ <%= verification_url(id: @signed_id) %>
@@ -0,0 +1,3 @@
1
+ Password reset email
2
+
3
+ <%= edit_recovery_url(id: @signed_id) %>
@@ -0,0 +1,17 @@
1
+ <h2>
2
+ Reset your password
3
+ </h2>
4
+
5
+ <p>
6
+ <%= link_to "Sign in to your account" %>
7
+ </p>
8
+
9
+ <%= form_with model: @user, url: recovery_path(id: params[:id]), method: :patch do |form| %>
10
+ <%= form.label :password %>
11
+ <%= form.password_field :password, autocomplete: "new-password", required: true %>
12
+
13
+ <%= form.label :password_confirmation %>
14
+ <%= form.password_field :password_confirmation, autocomplete: "new-password", required: true %>
15
+
16
+ <%= form.button "Update password", name: nil %>
17
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <h2>
2
+ Recover your password
3
+ </h2>
4
+
5
+ <p>
6
+ <%= link_to "Sign in to your account", new_session_path %>
7
+ </p>
8
+
9
+ <%= form_with url: recoveries_path do |form| %>
10
+ <%= form.label :email %>
11
+ <%= form.email_field :email, autofocus: true, autocomplete: "email", required: true %>
12
+
13
+ <%= form.button "Recover", name: nil %>
14
+ <% end -%>
@@ -0,0 +1,23 @@
1
+ <h2>
2
+ Sign up for a new account
3
+ </h2>
4
+
5
+ <p>
6
+ <%= link_to "Sign in to an existing account", new_session_path %>
7
+ </p>
8
+
9
+ <%= form_with model: @user, url: registrations_path do |form| %>
10
+ <div>
11
+ <%= form.label :email %>
12
+ <%= form.email_field :email, autofocus: true, autocomplete: "email", required: true %>
13
+ </div>
14
+ <div>
15
+ <%= form.label :password %>
16
+ <%= form.password_field :password, autocomplete: "new-password", required: true %>
17
+ </div>
18
+ <div>
19
+ <%= form.label :password_confirmation %>
20
+ <%= form.password_field :password_confirmation, autocomplete: "new-password", required: true %>
21
+ </div>
22
+ <%= form.button "Sign up", name: nil %>
23
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <tr id="<%= dom_id session %>">
2
+ <td><%= truncate session.user_agent %></td>
3
+ <td><%= session.ip_address %></td>
4
+ <td><%= session.created_at %></td>
5
+ <td>
6
+ <%= button_to "Delete", session, method: :delete %>
7
+ </td>
8
+ </tr>
@@ -0,0 +1,21 @@
1
+ <h2>
2
+ Sessions
3
+ </h2>
4
+
5
+ <div>
6
+ <table id="sessions">
7
+ <thead>
8
+ <tr>
9
+ <th scope="col">User Agent</th>
10
+ <th scope="col">IP Address</th>
11
+ <th scope="col">Created</th>
12
+ <th scope="col">
13
+ <span class="sr-only">Edit</span>
14
+ </th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <%= render @sessions %>
19
+ </tbody>
20
+ </table>
21
+ </div>
@@ -0,0 +1,15 @@
1
+ <h2>
2
+ Sign in to your account
3
+ </h2>
4
+
5
+ <p>
6
+ <%= link_to "sign up for a new account", new_registration_path %>
7
+ </p>
8
+
9
+ <%= form_with model: @session do |form| %>
10
+ <%= form.label :email %>
11
+ <%= form.email_field :email, autofocus: true, autocomplete: "email", required: true %>
12
+ <%= form.label :password %>
13
+ <%= form.password_field :password, autocomplete: "current-password", required: true %>
14
+ <%= form.button "Sign in", name: nil %>
15
+ <% end -%>
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ scope module: :avocado do
3
+ resources :recoveries, only: %i[new create edit update]
4
+ resources :registrations, only: %i[new create]
5
+ resources :sessions, only: %i[index new create destroy]
6
+ resources :verifications, only: %i[show create]
7
+ end
8
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ module Authentication
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ before_action :set_current_request_details
9
+ before_action :authenticate
10
+
11
+ helper_method :current_user
12
+ helper_method :signed_in?
13
+ helper_method :current_session
14
+ end
15
+
16
+ def current_user
17
+ Current.user
18
+ end
19
+
20
+ def signed_in?
21
+ current_user.present?
22
+ end
23
+
24
+ def current_session
25
+ Current.session
26
+ end
27
+
28
+ private
29
+
30
+ def authenticate
31
+ if session_from_token
32
+ Current.session = session_from_token
33
+ else
34
+ redirect_to new_session_path
35
+ end
36
+ end
37
+
38
+ def sign_in(user)
39
+ ::Session.create!(user: user).tap do |session|
40
+ cookies.signed.permanent[:session_token] = {value: session.id, httponly: true}
41
+ end
42
+ end
43
+
44
+ def session_from_token
45
+ ::Session.find_by_id(cookies.signed[:session_token])
46
+ end
47
+
48
+ def set_current_request_details
49
+ Current.user_agent = request.user_agent
50
+ Current.ip_address = request.ip
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Current < ActiveSupport::CurrentAttributes
4
+ attribute :session,
5
+ :user,
6
+ :user_agent,
7
+ :ip_address
8
+
9
+ def session=(session)
10
+ super
11
+ self.user = session.user
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "avocado"
4
+ require "rails/engine"
5
+
6
+ module Avocado
7
+ class Engine < Rails::Engine
8
+ end
9
+ end
@@ -1,17 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/concern"
4
-
5
3
  module Avocado
6
- module Mailer
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- before_action :set_user
11
- before_action :set_signed_id
4
+ class Mailer < ApplicationMailer
5
+ before_action :set_user
6
+ before_action :set_signed_id
12
7
 
13
- default to: -> { @user.email }
14
- end
8
+ default to: -> { @user.email }
15
9
 
16
10
  def email_affirmation
17
11
  mail
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ module Session
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ belongs_to :user
9
+
10
+ scope :newest_first, -> { order(created_at: :desc) }
11
+ end
12
+ end
13
+ end
data/lib/avocado/user.rb CHANGED
@@ -1,17 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/concern"
4
-
5
3
  module Avocado
6
4
  module User
7
5
  extend ActiveSupport::Concern
8
6
 
9
7
  included do
10
8
  include UserEmail
11
- include UserEmailAffirmation
12
- include UserEmailVerification
9
+ include UserTokens
13
10
  include UserPassword
14
- include UserPasswordReset
11
+
12
+ has_many :sessions
13
+
14
+ scope :newest_first, -> { order(created_at: :desc) }
15
+ scope :verified, -> { where(verified: true) }
15
16
  end
16
17
  end
17
18
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/concern"
4
-
5
3
  module Avocado
6
4
  module UserEmail
7
5
  extend ActiveSupport::Concern
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/concern"
4
-
5
3
  module Avocado
6
4
  module UserPassword
7
5
  extend ActiveSupport::Concern
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avocado
4
+ module UserTokens
5
+ extend ActiveSupport::Concern
6
+
7
+ EXPIRES_FAST = 16.minutes
8
+ EXPIRES_LATER = 64.minutes
9
+ EXPIRES_LONG = 2_048.minutes
10
+
11
+ included do
12
+ generates_token_for :email_affirmation, expires_in: EXPIRES_FAST
13
+
14
+ generates_token_for :email_verification, expires_in: EXPIRES_LONG do
15
+ email
16
+ end
17
+
18
+ generates_token_for :password_reset, expires_in: EXPIRES_LATER do
19
+ password_digest_salt
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def password_digest_salt
26
+ password_from_digest.salt[-10..]
27
+ end
28
+
29
+ def password_from_digest
30
+ BCrypt::Password.new(password_digest)
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avocado
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/avocado.rb CHANGED
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "avocado/version"
3
+ require_relative "avocado/engine"
4
4
 
5
5
  module Avocado
6
6
  class Error < StandardError; end
7
7
 
8
+ autoload :Authentication, "avocado/authentication"
9
+ autoload :Current, "avocado/current"
8
10
  autoload :Mailer, "avocado/mailer"
11
+ autoload :Session, "avocado/session"
9
12
  autoload :User, "avocado/user"
10
13
  autoload :UserEmail, "avocado/user_email"
11
- autoload :UserEmailAffirmation, "avocado/user_email_affirmation"
12
- autoload :UserEmailVerification, "avocado/user_email_verification"
14
+ autoload :UserTokens, "avocado/user_tokens"
13
15
  autoload :UserPassword, "avocado/user_password"
14
- autoload :UserPasswordReset, "avocado/user_password_reset"
15
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avocado
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Jankowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-18 00:00:00.000000000 Z
11
+ date: 2023-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -80,24 +80,41 @@ files:
80
80
  - LICENSE.txt
81
81
  - README.md
82
82
  - Rakefile
83
+ - app/controllers/avocado/base_controller.rb
84
+ - app/controllers/avocado/recoveries_controller.rb
85
+ - app/controllers/avocado/registrations_controller.rb
86
+ - app/controllers/avocado/sessions_controller.rb
87
+ - app/controllers/avocado/verifications_controller.rb
88
+ - app/views/avocado/mailer/email_affirmation.text.erb
89
+ - app/views/avocado/mailer/email_verification.text.erb
90
+ - app/views/avocado/mailer/password_reset.text.erb
91
+ - app/views/avocado/recoveries/edit.html.erb
92
+ - app/views/avocado/recoveries/new.html.erb
93
+ - app/views/avocado/registrations/new.html.erb
94
+ - app/views/avocado/sessions/_session.html.erb
95
+ - app/views/avocado/sessions/index.html.erb
96
+ - app/views/avocado/sessions/new.html.erb
83
97
  - config.ru
98
+ - config/routes.rb
84
99
  - lib/avocado.rb
100
+ - lib/avocado/authentication.rb
101
+ - lib/avocado/current.rb
102
+ - lib/avocado/engine.rb
85
103
  - lib/avocado/mailer.rb
104
+ - lib/avocado/session.rb
86
105
  - lib/avocado/user.rb
87
106
  - lib/avocado/user_email.rb
88
- - lib/avocado/user_email_affirmation.rb
89
- - lib/avocado/user_email_verification.rb
90
107
  - lib/avocado/user_password.rb
91
- - lib/avocado/user_password_reset.rb
108
+ - lib/avocado/user_tokens.rb
92
109
  - lib/avocado/version.rb
93
110
  - sig/avocado.rbs
94
- homepage: https://github.com/unicorngroomers/avocado
111
+ homepage: https://github.com/tcuwp/avocado
95
112
  licenses:
96
113
  - MIT
97
114
  metadata:
98
- homepage_uri: https://github.com/unicorngroomers/avocado
99
- source_code_uri: https://github.com/unicorngroomers/avocado
100
- changelog_uri: https://github.com/unicorngroomers/avocado/blob/main/CHANGELOG.md
115
+ homepage_uri: https://github.com/tcuwp/avocado
116
+ source_code_uri: https://github.com/tcuwp/avocado
117
+ changelog_uri: https://github.com/tcuwp/avocado/blob/main/CHANGELOG.md
101
118
  post_install_message:
102
119
  rdoc_options: []
103
120
  require_paths:
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/concern"
4
-
5
- module Avocado
6
- module UserEmailAffirmation
7
- extend ActiveSupport::Concern
8
-
9
- TOKEN_EXPIRATION = 16.minutes
10
-
11
- included do
12
- generates_token_for :email_affirmation, expires_in: TOKEN_EXPIRATION
13
- end
14
- end
15
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/concern"
4
-
5
- module Avocado
6
- module UserEmailVerification
7
- extend ActiveSupport::Concern
8
-
9
- TOKEN_EXPIRATION = 2_048.minutes
10
-
11
- included do
12
- generates_token_for :email_verification, expires_in: TOKEN_EXPIRATION do
13
- email
14
- end
15
- end
16
- end
17
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/concern"
4
-
5
- module Avocado
6
- module UserPasswordReset
7
- extend ActiveSupport::Concern
8
-
9
- TOKEN_EXPIRATION = 64.minutes
10
-
11
- included do
12
- generates_token_for :password_reset, expires_in: TOKEN_EXPIRATION do
13
- password_digest_salt
14
- end
15
- end
16
-
17
- private
18
-
19
- def password_digest_salt
20
- password_from_digest.salt[-10..]
21
- end
22
-
23
- def password_from_digest
24
- BCrypt::Password.new(password_digest)
25
- end
26
- end
27
- end