public
Created

Sinatra Authentication Issue

  • Download Gist
app.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
require 'sinatra'
require 'haml'
require 'digest/sha1'
require 'rack-flash'
require 'mongoid'
require 'sinatra-authentication'
 
use Rack::Session::Cookie, :secret => 'skey'
use Rack::Flash
 
#MongoDB Config
Mongoid.configure do |config|
name = "blog"
host = "localhost"
config.master = Mongo::Connection.new.db(name)
config.slaves = [
Mongo::Connection.new(host, 27017, :slave_ok => true).db(name)
]
config.persist_in_safe_mode = false
end
 
get '/' do
"Hello World" # -> Works
end
 
get '/haml' do
haml :test # -> Works
end
 
get '/private' do
login_required
'My Super Top-Secret Page' # -> Redirects to /login (Works)
end
config.ru
Ruby
1 2 3 4 5
require 'rubygems'
require 'sinatra'
require './app.rb'
 
run Sinatra::Application
error.log
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Errno::ENOENT - No such file or directory - /opt/nginx/html/raptor.patrickarlt.com/views/layout.haml:
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/tilt-1.2.2/lib/tilt.rb:109:in `binread'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/tilt-1.2.2/lib/tilt.rb:109:in `block in initialize'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/tilt-1.2.2/lib/tilt.rb:110:in `call'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/tilt-1.2.2/lib/tilt.rb:110:in `initialize'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:508:in `new'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:508:in `block in compile_template'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/tilt-1.2.2/lib/tilt.rb:344:in `fetch'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:489:in `compile_template'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:473:in `render'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:480:in `block in render'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:480:in `catch'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:480:in `render'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:390:in `haml'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-authentication-0.4.1/lib/sinatra-authentication.rb:48:in `block in registered'
/usr/local/Cellar/ruby/1.9.2-p0/lib/ruby/gems/1.9.1/gems/sinatra-1.1.2/lib/sinatra/base.rb:1058:in `call'
views/test.haml
Haml
1
%strong{:class => "code", :id => "message"} Hello HAML!

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.