revise_auth 0.4.0 → 0.4.1
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/README.md +16 -0
 - data/lib/revise_auth/route_constraint.rb +2 -0
 - data/lib/revise_auth/routes.rb +7 -4
 - data/lib/revise_auth/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0f24ed4142195b9a07307505fe8f3c5c88bd2da2c7740f69dc02ac4d65154d07
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2d1a7e07138b6806ac73dd290666542f8eab2ad3b83acb11a889339b19a59d23
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 426b8d1832b1ff2eab5e44da0f67833fdacfdd19fe8ed02690140005435554f05e287cc2ff048336a0ca58355fcf01eef85b598facff497aec397a14a4296647
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e3eb35bed4d5484e566e575841bb5edff8c79c7e7c3a07875aa21d2bb97e7e21f8f1d0815167fd2cdd0517083a51b4a4eb389104b6ae2eb323abdeab44d77cf0
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -55,6 +55,22 @@ class ApplicationController < ActionController::Base 
     | 
|
| 
       55 
55 
     | 
    
         
             
            end
         
     | 
| 
       56 
56 
     | 
    
         
             
            ```
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
      
 58 
     | 
    
         
            +
            ### Routing Constraints
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            You can use any of the authentication functionality in your routes using the `ReviseAuth::RouteConstraint` class.
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            The following will draw routes only if the user is signed in:
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 65 
     | 
    
         
            +
            authenticated ->{ _1.admin? } do
         
     | 
| 
      
 66 
     | 
    
         
            +
              resource :admin
         
     | 
| 
      
 67 
     | 
    
         
            +
            end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            authenticated do
         
     | 
| 
      
 70 
     | 
    
         
            +
              resource :dashboard
         
     | 
| 
      
 71 
     | 
    
         
            +
            end
         
     | 
| 
      
 72 
     | 
    
         
            +
            ```
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
       58 
74 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       59 
75 
     | 
    
         | 
| 
       60 
76 
     | 
    
         
             
            If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.
         
     | 
    
        data/lib/revise_auth/routes.rb
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module ActionDispatch::Routing
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Mapper
         
     | 
| 
      
 3 
     | 
    
         
            +
                # Adds helpers for config/routes.rb to constraint routes with authentication
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       3 
5 
     | 
    
         
             
                def revise_auth
         
     | 
| 
       4 
6 
     | 
    
         
             
                  scope module: :revise_auth do
         
     | 
| 
       5 
7 
     | 
    
         
             
                    revise_registration
         
     | 
| 
         @@ -21,10 +23,11 @@ module ActionDispatch::Routing 
     | 
|
| 
       21 
23 
     | 
    
         
             
                  end
         
     | 
| 
       22 
24 
     | 
    
         
             
                end
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
                def authenticated(block = nil)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  constraints ->(request) {
         
     | 
| 
      
 28 
     | 
    
         
            +
                    rc = ReviseAuth::RouteConstraint.new(request)
         
     | 
| 
      
 29 
     | 
    
         
            +
                    rc.user_signed_in? && (block.nil? || block.call(rc.current_user))
         
     | 
| 
      
 30 
     | 
    
         
            +
                  } do
         
     | 
| 
       28 
31 
     | 
    
         
             
                    yield
         
     | 
| 
       29 
32 
     | 
    
         
             
                  end
         
     | 
| 
       30 
33 
     | 
    
         
             
                end
         
     | 
    
        data/lib/revise_auth/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: revise_auth
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Chris Oliver
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-10-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       104 
104 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       105 
105 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       106 
106 
     | 
    
         
             
            requirements: []
         
     | 
| 
       107 
     | 
    
         
            -
            rubygems_version: 3.4. 
     | 
| 
      
 107 
     | 
    
         
            +
            rubygems_version: 3.4.20
         
     | 
| 
       108 
108 
     | 
    
         
             
            signing_key:
         
     | 
| 
       109 
109 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       110 
110 
     | 
    
         
             
            summary: Simple authentication for Ruby on Rails apps
         
     |