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
-
#login ⇒ String
Log a user in based on the :username and :password key in the request hash.
-
#logout ⇒ Object
Log the user out and redirect him back to the previous page.
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
#login ⇒ String
Log a user in based on the :username and :password key in the request hash.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ramaze/helper/auth.rb', line 33 def login if trait[:auth_post_only] and !request.post? return auth_template end @username, password = request[:username, :password] answer(request.referer) if auth_login(@username, password) return auth_template end |
#logout ⇒ Object
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 |