This repository was archived by the owner on Nov 25, 2021. It is now read-only.
forked from NoamB/sorcery
-
Notifications
You must be signed in to change notification settings - Fork 0
Basic Sinatra usage
sepastian edited this page Sep 12, 2011
·
4 revisions
Sorcery supports both classic style AND modular style since v0.5.2
First we'll require sinatra and enable sessions:
# myapp.rb
require 'sinatra'
enable :sessionsSorcery comes in like this (order IS important):
# myapp.rb
require 'sorcery'
require_relative 'sorcery_config'
# sorcery_config.rb
Sorcery::Controller::Config.submodules = [:user_activation, :http_basic_auth, :remember_me, :reset_password, :session_timeout, :brute_force_protection, :activity_logging, :oauth]
Sorcery::Controller::Config.configure do |config|
...
config.user_config do |user|
...
end
...
end
include Sorcery::Controller::Adapters::Sinatra
include Sorcery::ControllerBefore filters can be added like this:
# myapp.rb
['/logout'].each do |patt|
before patt do
require_login
end
end
before '/login/http' do
require_login_from_http_basic
endFor more examples check out the example Sinatra app.