Class: QuoVadis::SessionsController
- Inherits:
-
QuoVadisController
- Object
- ApplicationController
- QuoVadisController
- QuoVadis::SessionsController
- Defined in:
- app/controllers/quo_vadis/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/quo_vadis/sessions_controller.rb', line 20 def create account = QuoVadis.find_account_by_identifier_in_params params unless account qv.log nil, Log::LOGIN_UNKNOWN, identifier: QuoVadis.identifier_value_in_params(params) flash.now[:alert] = QuoVadis.translate 'flash.login.failed' render :new, status: :unprocessable_entity return end unless account.password.authenticate params[:password] qv.log account, Log::LOGIN_FAILURE flash.now[:alert] = QuoVadis.translate 'flash.login.failed' render :new, status: :unprocessable_entity return end # no params[:remember] => use QuoVadis.session_lifetime # params[:remember] == 0 => use :session # params[:remember] == 1 => use QuoVadis.session_lifetime browser_session = params[:remember] == '0' login account.model, browser_session flash[:notice] = QuoVadis.translate 'flash.login.success' redirect_to qv.path_after_authentication end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/quo_vadis/sessions_controller.rb', line 50 def destroy if params[:id] # other session current_qv_session = qv.session current_qv_session.account.sessions.destroy params[:id] qv.log current_qv_session.account, Log::LOGOUT_OTHER flash[:notice] = QuoVadis.translate 'flash.logout.other' redirect_to action: :index, status: :see_other else # this session qv.log authenticated_model.qv_account, Log::LOGOUT qv.logout flash[:notice] = QuoVadis.translate 'flash.logout.self' redirect_to main_app.root_path, status: :see_other end end |
#index ⇒ Object
10 11 12 13 |
# File 'app/controllers/quo_vadis/sessions_controller.rb', line 10 def index @qv_session = qv.session @qv_sessions = @qv_session.account.sessions.new_to_old end |
#new ⇒ Object
16 17 |
# File 'app/controllers/quo_vadis/sessions_controller.rb', line 16 def new end |