Class: Merb::Authentication::Strategies::FormWithAccount

Inherits:
Merb::Authentication::Strategy
  • Object
show all
Defined in:
lib/heedley-merb-auth-with-account/strategies/password_form_with_account.rb

Instance Method Summary collapse

Instance Method Details

#redirect!(url, opts = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/heedley-merb-auth-with-account/strategies/password_form_with_account.rb', line 28

def redirect!(url, opts = {})
  self.headers["Location"] = url
  self.status = opts[:permanent] ? 301 : 302
  self.status = opts[:status] if opts[:status]
  if ROOT_DOMAIN
    url = url.gsub(Regexp.new("\/([a-zA-Z0-9]+)\.#{ROOT_DOMAIN}\/"),'/')
  end

  self.body   = opts[:message] || "<div>You are being redirected to <a href='#{url}'>#{url}</a></div>"
  halt!
  return true
end

#run!Object



41
42
43
44
45
46
47
48
# File 'lib/heedley-merb-auth-with-account/strategies/password_form_with_account.rb', line 41

def run!
   if params[:account_subdomain]
      user = User.authenticate(request.params[:login], request.params[:password], params[:account_subdomain])
   else
     raise "missing :account_subdomain route param #{params.inspect}"
   end
   user
end