Class: Admin::SessionsController
Instance Method Summary
collapse
#webauthn_auth_options, #webauthn_authenticate!, #webauthn_relying_party
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/admin/sessions_controller.rb', line 17
def create
if (admin_user = webauthn_authenticate!)
record_sign_in!(admin_user)
session[:admin_user_id] = admin_user.id
redirect_to admin_dashboard_path, notice: "You have been logged in"
elsif (admin_user = Admin::User.authenticate_by(session_params.slice(:email, :password)))
record_sign_in!(admin_user)
session[:admin_user_id] = admin_user.id
redirect_to admin_dashboard_path, notice: "You have been logged in"
else
admin_user = Admin::User.new(session_params.slice(:email, :password))
admin_user.errors.add(:email, "Invalid email or password")
render :new, status: :unprocessable_entity, locals: { admin_user: }
end
end
|
#destroy ⇒ Object
38
39
40
41
42
43
44
|
# File 'app/controllers/admin/sessions_controller.rb', line 38
def destroy
record_sign_out!(current_admin_user)
session[:admin_user_id] = nil
redirect_to admin_dashboard_path, notice: "You have been logged out"
end
|
#new ⇒ Object
11
12
13
14
15
|
# File 'app/controllers/admin/sessions_controller.rb', line 11
def new
return redirect_to admin_dashboard_path if admin_signed_in?
render :new, locals: { admin_user: Admin::User.new }
end
|