Class: Chowder::Base

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

Direct Known Subclasses

Basic, OpenID

Constant Summary collapse

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

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