sinatra-single-user-auth 0.1 → 0.2
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.
- data/lib/sinatra/simple_auth.rb +7 -6
 - data/sinatra-single-user-auth.gemspec +1 -1
 - data/test/sinatra_modular_app.rb +1 -0
 - metadata +2 -2
 
    
        data/lib/sinatra/simple_auth.rb
    CHANGED
    
    | 
         @@ -12,18 +12,18 @@ module Sinatra 
     | 
|
| 
       12 
12 
     | 
    
         
             
                      session[:arni] = true
         
     | 
| 
       13 
13 
     | 
    
         
             
                      redirect_back_or_default(settings.home)
         
     | 
| 
       14 
14 
     | 
    
         
             
                    end
         
     | 
| 
       15 
     | 
    
         
            -
                    redirect to( 
     | 
| 
      
 15 
     | 
    
         
            +
                    redirect to("#{settings.context}login")
         
     | 
| 
       16 
16 
     | 
    
         
             
                  end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                  def logout!
         
     | 
| 
       19 
19 
     | 
    
         
             
                    session.clear
         
     | 
| 
       20 
     | 
    
         
            -
                    redirect to( 
     | 
| 
      
 20 
     | 
    
         
            +
                    redirect to(settings.context)
         
     | 
| 
       21 
21 
     | 
    
         
             
                  end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                  def protected!
         
     | 
| 
       24 
24 
     | 
    
         
             
                    unless authorized?
         
     | 
| 
       25 
25 
     | 
    
         
             
                      store_location
         
     | 
| 
       26 
     | 
    
         
            -
                      redirect to( 
     | 
| 
      
 26 
     | 
    
         
            +
                      redirect to("#{settings.context}login")
         
     | 
| 
       27 
27 
     | 
    
         
             
                    end
         
     | 
| 
       28 
28 
     | 
    
         
             
                  end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
         @@ -47,16 +47,17 @@ module Sinatra 
     | 
|
| 
       47 
47 
     | 
    
         
             
                  app.set :username, 'username'
         
     | 
| 
       48 
48 
     | 
    
         
             
                  app.set :password, 'password'
         
     | 
| 
       49 
49 
     | 
    
         
             
                  app.set :home, '/'
         
     | 
| 
      
 50 
     | 
    
         
            +
                  app.set :context, '/'
         
     | 
| 
       50 
51 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                  app.post  
     | 
| 
      
 52 
     | 
    
         
            +
                  app.post "#{app.context}login/?" do
         
     | 
| 
       52 
53 
     | 
    
         
             
                    auth!(params[:password],params[:username])
         
     | 
| 
       53 
54 
     | 
    
         
             
                  end
         
     | 
| 
       54 
55 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                  app.delete  
     | 
| 
      
 56 
     | 
    
         
            +
                  app.delete "#{app.context}logout/?" do
         
     | 
| 
       56 
57 
     | 
    
         
             
                    logout!
         
     | 
| 
       57 
58 
     | 
    
         
             
                  end
         
     | 
| 
       58 
59 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                  app.get  
     | 
| 
      
 60 
     | 
    
         
            +
                  app.get "#{app.context}logout/?" do
         
     | 
| 
       60 
61 
     | 
    
         
             
                    logout!
         
     | 
| 
       61 
62 
     | 
    
         
             
                  end
         
     | 
| 
       62 
63 
     | 
    
         
             
                end
         
     | 
| 
         @@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__) 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       5 
5 
     | 
    
         
             
              s.name        = "sinatra-single-user-auth"
         
     | 
| 
       6 
     | 
    
         
            -
              s.version     = '0. 
     | 
| 
      
 6 
     | 
    
         
            +
              s.version     = '0.2'
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.authors     = ["Kingsley Hendrickse","Vasily Polovnyov"]
         
     | 
| 
       9 
9 
     | 
    
         
             
              s.email       = ["kingsley@masterthought.net","vasily@polovnyov.ru"]
         
     | 
    
        data/test/sinatra_modular_app.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sinatra-single-user-auth
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: '0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: '0.2'
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2013-07- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2013-07-12 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: sinatra
         
     |