Class: UserSessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UserSessionsController
- Defined in:
- vendor/plugins/blacklight/app/controllers/user_sessions_controller.rb,
vendor/plugins/hydra_repository/app/controllers/user_sessions_controller.rb
Instance Method Summary (collapse)
- - (Object) create
- - (Object) destroy
-
- (Object) new
def create.
-
- (Object) superuser
toggle to set superuser_mode in session Only allows user who can be superusers to set this value in session.
Methods inherited from ApplicationController
#current_user, #default_html_head, #error, #extra_head_content, #javascript_includes, #stylesheet_links, #user_class
Methods included from HydraAccessControlsHelper
#editor?, #reader?, #test_permission
Instance Method Details
- (Object) create
27 28 29 30 31 32 33 34 35 36 |
# File 'vendor/plugins/blacklight/app/controllers/user_sessions_controller.rb', line 27 def create @user_session = UserSession.new(params[:user_session]) if @user_session.save flash[:notice] = "Welcome #{@user_session.login}!" redirect_to root_path else flash.now[:error] = "Couldn't locate a user with those credentials" render :action => :new end end |
- (Object) destroy
38 39 40 41 42 |
# File 'vendor/plugins/blacklight/app/controllers/user_sessions_controller.rb', line 38 def destroy current_user_session.destroy flash[:notice] = "You have successfully logged out." redirect_to root_path end |
- (Object) new
def create
if user = User.authenticate(params[:email], params[:password]) self.current_user = user user.update_attribute(:last_login, Time.now) flash[:notice] = "Welcome #{user.login}!" redirect_to root_path else flash.now[:error] = "Couldn't locate a user with those credentials" render :action => :new end end def destroy session[:user_id] = nil flash[:notice] = "You have successfully logged out." redirect_to root_path end
23 24 25 |
# File 'vendor/plugins/blacklight/app/controllers/user_sessions_controller.rb', line 23 def new @user_session = UserSession.new end |
- (Object) superuser
toggle to set superuser_mode in session Only allows user who can be superusers to set this value in session
4 5 6 7 8 9 10 11 |
# File 'vendor/plugins/hydra_repository/app/controllers/user_sessions_controller.rb', line 4 def superuser if session[:superuser_mode] session[:superuser_mode] = nil elsif current_user.can_be_superuser? session[:superuser_mode] = true end redirect_to :back end |