Class: Admin::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Admin::SessionsController
- Defined in:
- app/controllers/admin/sessions_controller.rb
Instance Attribute Summary collapse
-
#admin_user ⇒ Object
readonly
Returns the value of attribute admin_user.
Instance Method Summary collapse
Methods included from Koi::Controller::RecordsAuthentication
#create_admin_session!, #destroy_admin_sessions!
Methods included from Koi::Controller::HasWebauthn
#webauthn_authenticate!, #webauthn_nickname, #webauthn_register!, #webauthn_relying_party
Instance Attribute Details
#admin_user ⇒ Object (readonly)
Returns the value of attribute admin_user.
16 17 18 |
# File 'app/controllers/admin/sessions_controller.rb', line 16 def admin_user @admin_user end |
Instance Method Details
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/admin/sessions_controller.rb', line 28 def create if session_params[:response].present? create_session_with_webauthn elsif session_params[:token].present? create_session_with_token elsif session_params[:password].present? create_session_with_password elsif session_params[:email].present? # conversational flow, ask for password regardless of email @admin_user = Admin::User.new(session_params.slice(:email)) render(:password, status: :unprocessable_content, locals: { admin_user: }) else # invalid request, re-render new @admin_user = Admin::User.new render(:new, status: :unprocessable_content, locals: { admin_user: }) end end |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/admin/sessions_controller.rb', line 48 def destroy destroy_admin_sessions!(Koi::Current.admin_user) redirect_to new_admin_session_path end |