Module: Ramaze::Helper::User
- Defined in:
- lib/ramaze/helper/user.rb
Overview
This helper provides a convenience wrapper for handling authentication and persistence of users.
Example:
class MainController < Ramaze::Controller
def index
if logged_in?
"Hello #{user.name}"
else
A('login', :href => Rs(:login))
end
end
def login
user_login if request.post?
end
end
Defined Under Namespace
Classes: Wrapper
Instance Method Summary collapse
- #logged_in? ⇒ Boolean
-
#user ⇒ Object
return existing or instantiate User::Wrapper.
-
#user_login(creds = request.params) ⇒ Object
shortcut for user.user_login but default argument are request.params.
-
#user_logout ⇒ Object
shortcut for user.user_logout.
Instance Method Details
#logged_in? ⇒ Boolean
43 44 45 |
# File 'lib/ramaze/helper/user.rb', line 43 def logged_in? user._logged_in? end |
#user ⇒ Object
return existing or instantiate User::Wrapper
25 26 27 28 29 |
# File 'lib/ramaze/helper/user.rb', line 25 def user model = ancestral_trait[:user_model] ||= ::User callback = ancestral_trait[:user_callback] ||= nil STATE[:user] ||= Wrapper.new(model, callback) end |
#user_login(creds = request.params) ⇒ Object
shortcut for user.user_login but default argument are request.params
33 34 35 |
# File 'lib/ramaze/helper/user.rb', line 33 def user_login(creds = request.params) user._login(creds) end |
#user_logout ⇒ Object
shortcut for user.user_logout
39 40 41 |
# File 'lib/ramaze/helper/user.rb', line 39 def user_logout user._logout end |