Class: UserSessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UserSessionsController
- Defined in:
- app/controllers/user_sessions_controller.rb
Overview
Create, destroy sessions by letting users login and logout. When the user does not login, he/she is considered to be the anonymous user.
Instance Method Summary collapse
Methods included from Zena::App
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/user_sessions_controller.rb', line 14 def create User.send(:with_scope, :find => {:conditions => ['site_id = ?', visitor.site.id]}) do @user_session = UserSession.new(:login=>params[:login], :password=>params[:password]) if @user_session.save #flash.now[:notice] = _("Successfully logged in.") redirect_to redirect_after_login else flash[:notice] = _("Invalid login or password.") # FIXME: find a better way to lock without blocking the process. # Also lock longer and longer (exponentially). sleep(2) redirect_to login_path end end end |
#destroy ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/user_sessions_controller.rb', line 30 def destroy if @user_session = UserSession.find @user_session.destroy reset_session #flash.now[:notice] = _("Successfully logged out.") redirect_to params[:redirect] || home_path(:prefix => prefix) else redirect_to home_path(:prefix => prefix) end end |
#new ⇒ Object
/login
9 10 11 12 |
# File 'app/controllers/user_sessions_controller.rb', line 9 def new @node = visitor.site.root_node render_and_cache :mode => '+login' end |