This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
require 'rack/flash' | |
require 'warden' | |
require 'slim' | |
require 'sequel' | |
require 'sqlite3' | |
DB = Sequel.sqlite | |
DB.create_table :users do | |
primary_key :id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Warden::Strategies.add(:basic) do | |
def auth | |
@auth ||= Rack::Auth::Basic::Request.new(env) | |
end | |
def valid? | |
auth.provided? && auth.basic? && auth.credentials | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module App | |
class Users < App::Base | |
use Rack::Parser | |
helpers do | |
def cycle | |
@cycle ||= %w{odd even}.cycle | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I am using this for an API. So auth key is passed as user name. | |
Warden::Strategies.add(:basic) do | |
def auth | |
@auth ||= Rack::Auth::Basic::Request.new(env) | |
end | |
def store? | |
false |