Module: Authpds::Controllers::AuthpdsUserSessionsController

Defined in:
lib/authpds/controllers/authpds_user_sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

DELETE /user_sessions/1 GET /logout



28
29
30
31
32
33
# File 'lib/authpds/controllers/authpds_user_sessions_controller.rb', line 28

def destroy
	user_session = UserSession.find
	logout_url = user_session.logout_url(params)
	user_session.destroy unless user_session.nil?
	redirect_to user_session_redirect_url(logout_url)
end

#newObject

GET /user_sessions/new GET /login

Raises:

  • (RuntimeError)


7
8
9
10
11
12
# File 'lib/authpds/controllers/authpds_user_sessions_controller.rb', line 7

def new
	@user_session = UserSession.new(params)
	@user_session.(params) and return if performed?
	redirect_to @user_session.(params) unless @user_session..nil?
	raise RuntimeError.new( "Error in #{self.class}.\nNo login url defined") if @user_session..nil?
end

#validateObject

GET /validate



15
16
17
18
19
20
21
22
23
24
# File 'lib/authpds/controllers/authpds_user_sessions_controller.rb', line 15

def validate
	@user_session = UserSession.new(params[:user_session])
	@user_session.save do |result|
		@user_session.errors.each_full {|error|
			flash[:error] = "There was an error logging in. #{error}"
			logger.error("Error in #{self.class} while saving user session. #{error}")
		} unless result
    	redirect_to (params[:return_url].nil?) ? root_url : params[:return_url]
	end
end