authentication-zero 2.16.32 → 2.16.33
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 +4 -4
 - data/Gemfile.lock +1 -1
 - data/README.md +5 -8
 - data/lib/authentication_zero/version.rb +1 -1
 - data/lib/generators/authentication/authentication_generator.rb +0 -5
 - data/lib/generators/authentication/templates/migrations/create_users_migration.rb.tt +3 -0
 - data/lib/generators/authentication/templates/models/account.rb.tt +1 -0
 - data/lib/generators/authentication/templates/models/current.rb.tt +5 -0
 - data/lib/generators/authentication/templates/models/user.rb.tt +10 -2
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e0192b708d0a77022c0ebcca72d6a67cddf4037e5412b78692b14871d8055dc3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: beadfc9974865abbc3a64783d863e7ecffd9ed61d8134cb3db219ef9ab73b4a9
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c1b8a91979fa37f3486241f6ff40b726809bc196433bc67d3cb509b4adfc2afaf73afc4037a931237d6d0757d9f05a9b7a0e32e82a99d89baedd2ffb808d8b74
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5c542b08d8a748b7b041849eb3bda327439ec9c07dd53d4eb62bafb4caf727f480b2a9c2e4001b6b26e7bb58d1a18e6deea3a2a7770b1d5f44cbd36ccf4b8913
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -70,14 +70,11 @@ Some artifacts are generated in the application, which makes it possible to impl 
     | 
|
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
            - Add `account_id` to each scoped table using `rails g migration add_account_to_projects account:references`.
         
     | 
| 
       72 
72 
     | 
    
         
             
            - Add `include AccountScoped` to scoped models. It set up the account relationship and default scope using the current account.
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
              - Use `redirect_to "/#{user.account_id}"` after sign-in.
         
     | 
| 
       79 
     | 
    
         
            -
              - Override `Current#user=` to also set the account, `super; self.account = user.account`.
         
     | 
| 
       80 
     | 
    
         
            -
              - etc...
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            #### Set Current.account through the URL. `http://myapp.com/:account_id`
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            - Add `require_relative "../lib/account_middleware"` to `config/application.rb`.
         
     | 
| 
      
 77 
     | 
    
         
            +
            - Add `config.middleware.use AccountMiddleware` to your application class.
         
     | 
| 
       81 
78 
     | 
    
         | 
| 
       82 
79 
     | 
    
         
             
            ## Development
         
     | 
| 
       83 
80 
     | 
    
         | 
| 
         @@ -54,11 +54,6 @@ class AuthenticationGenerator < Rails::Generators::Base 
     | 
|
| 
       54 
54 
     | 
    
         
             
                application "config.action_mailer.default_url_options = { host: \"localhost\", port: 3000 }", env: "development"
         
     | 
| 
       55 
55 
     | 
    
         
             
                application "config.action_mailer.default_url_options = { host: \"localhost\", port: 3000 }", env: "test"
         
     | 
| 
       56 
56 
     | 
    
         
             
                environment ratelimit_block, env: "production" if options.ratelimit?
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                if options.tenantable?
         
     | 
| 
       59 
     | 
    
         
            -
                  prepend_to_file "config/application.rb", "require_relative \"../lib/account_middleware\"\n"
         
     | 
| 
       60 
     | 
    
         
            -
                  application "config.middleware.use AccountMiddleware"
         
     | 
| 
       61 
     | 
    
         
            -
                end
         
     | 
| 
       62 
57 
     | 
    
         
             
              end
         
     | 
| 
       63 
58 
     | 
    
         | 
| 
       64 
59 
     | 
    
         
             
              def create_configuration_files
         
     | 
| 
         @@ -16,6 +16,9 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  t.string :provider
         
     | 
| 
       17 
17 
     | 
    
         
             
                  t.string :uid
         
     | 
| 
       18 
18 
     | 
    
         
             
                  <%- end -%>
         
     | 
| 
      
 19 
     | 
    
         
            +
                  <%- if options.tenantable? %>
         
     | 
| 
      
 20 
     | 
    
         
            +
                  t.references :account, null: false, foreign_key: true
         
     | 
| 
      
 21 
     | 
    
         
            +
                  <%- end -%>
         
     | 
| 
       19 
22 
     | 
    
         | 
| 
       20 
23 
     | 
    
         
             
                  t.timestamps
         
     | 
| 
       21 
24 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,5 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class User < ApplicationRecord
         
     | 
| 
       2 
2 
     | 
    
         
             
              has_secure_password
         
     | 
| 
      
 3 
     | 
    
         
            +
              <%- if options.tenantable? %>
         
     | 
| 
      
 4 
     | 
    
         
            +
              belongs_to :account
         
     | 
| 
      
 5 
     | 
    
         
            +
              <%- end -%>
         
     | 
| 
       3 
6 
     | 
    
         | 
| 
       4 
7 
     | 
    
         
             
              has_many :email_verification_tokens, dependent: :destroy
         
     | 
| 
       5 
8 
     | 
    
         
             
              has_many :password_reset_tokens, dependent: :destroy
         
     | 
| 
         @@ -31,15 +34,20 @@ class User < ApplicationRecord 
     | 
|
| 
       31 
34 
     | 
    
         
             
                self.verified = false
         
     | 
| 
       32 
35 
     | 
    
         
             
              end
         
     | 
| 
       33 
36 
     | 
    
         
             
              <%- if two_factor? %>
         
     | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
      
 37 
     | 
    
         
            +
              before_validation on: :create do
         
     | 
| 
       35 
38 
     | 
    
         
             
                self.otp_secret = ROTP::Base32.random
         
     | 
| 
       36 
39 
     | 
    
         
             
              end
         
     | 
| 
       37 
40 
     | 
    
         
             
              <%- end -%>
         
     | 
| 
       38 
41 
     | 
    
         
             
              <%- if webauthn? %>
         
     | 
| 
       39 
     | 
    
         
            -
               
     | 
| 
      
 42 
     | 
    
         
            +
              before_validation on: :create do
         
     | 
| 
       40 
43 
     | 
    
         
             
                self.webauthn_id = WebAuthn.generate_user_id
         
     | 
| 
       41 
44 
     | 
    
         
             
              end
         
     | 
| 
       42 
45 
     | 
    
         
             
              <%- end -%>
         
     | 
| 
      
 46 
     | 
    
         
            +
              <%- if options.tenantable? %>
         
     | 
| 
      
 47 
     | 
    
         
            +
              before_validation on: :create do
         
     | 
| 
      
 48 
     | 
    
         
            +
                self.account = Account.new
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
              <%- end -%>
         
     | 
| 
       43 
51 
     | 
    
         | 
| 
       44 
52 
     | 
    
         
             
              after_update if: :password_digest_previously_changed? do
         
     | 
| 
       45 
53 
     | 
    
         
             
                sessions.where.not(id: Current.session).delete_all
         
     |