Class: Chowder::Base

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/chowder.rb

Direct Known Subclasses

Basic, OpenID

Constant Summary collapse

LOGIN_VIEW =
"  <form action=\"/login\" method=\"POST\">\n    Login: <input type=\"text\" name=\"login\" /><br />\n    Password: <input type=\"password\" name=\"password\" /><br />\n    <input type=\"submit\" value=\"Login\" />\n  </form>\n  OpenID:\n  <form action=\"/openid/initiate\" method=\"POST\">\n    URL: <input type=\"text\" name=\"openid_identifier\" /><br />\n    <input type=\"submit\" value=\"Login\" />\n  </form>\n"

Instance Method Summary collapse

Constructor Details

#initialize(app = nil, *args, &block) ⇒ Base

Override this until in Sinatra supports it. See sinatra.lighthouseapp.com/projects/9779/tickets/160



25
26
27
28
# File 'lib/chowder.rb', line 25

def initialize(app=nil, *args, &block)
  @app = app
  @middleware = OpenStruct.new(:args => args, :block => block)
end

Instance Method Details

#authorize(user) ⇒ Object



30
31
32
# File 'lib/chowder.rb', line 30

def authorize(user)
  session[:current_user] = user
end

#find_login_templateObject



38
39
40
41
# File 'lib/chowder.rb', line 38

def 
  views_dir = self.options.views || "./views"
  template = Dir[File.join(views_dir, 'login.*')].first
end

#return_or_redirect_to(path) ⇒ Object



34
35
36
# File 'lib/chowder.rb', line 34

def return_or_redirect_to(path)
  redirect(session[:return_to] || path)
end