Module: Ramaze::Helper::Auth

Includes:
Traited
Defined in:
lib/ramaze/helper/auth.rb

Overview

The Auth helper can be used for authentication without using a model. This can be useful when working with very basic applications that don’t require database access.

If you’re looking for a way to do authentication using a model you should take a look at Helper::User instead.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(into) ⇒ Object



22
23
24
# File 'lib/ramaze/helper/auth.rb', line 22

def self.included(into)
  into.helper(:stack)
end

Instance Method Details

#loginString

Log a user in based on the :username and :password key in the request hash.

Returns:

  • (String)

    The login template in case the user’s login data was incorrect.



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ramaze/helper/auth.rb', line 33

def 
  if trait[:auth_post_only] and !request.post?
    return auth_template
  end

  @username, password = request[:username, :password]

  answer(request.referer) if (@username, password)

  return auth_template
end

#logoutObject

Log the user out and redirect him back to the previous page.



48
49
50
51
# File 'lib/ramaze/helper/auth.rb', line 48

def logout
  auth_logout
  redirect_referrer
end