diff options
author | Starfall <us@starfall.systems> | 2020-08-31 12:28:25 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2020-08-31 12:28:25 -0500 |
commit | c5bb91194f0df90ea9c59ea6af1bd985b295fb30 (patch) | |
tree | 47b303b2c64ff1920fb19d01093a08dc9fd20ac8 /app/controllers/auth | |
parent | 27ee0fc8c4c13c53f81ca3db781b9d0783b877e5 (diff) | |
parent | f715e8b51612820a18fa307e4465eb0c1a088f86 (diff) |
Merge branch 'glitch' into main
Diffstat (limited to 'app/controllers/auth')
-rw-r--r-- | app/controllers/auth/sessions_controller.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 441833e85..1cf6a0a59 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -39,6 +39,22 @@ class Auth::SessionsController < Devise::SessionsController store_location_for(:user, tmp_stored_location) if continue_after? end + def webauthn_options + user = find_user + + if user.webauthn_enabled? + options_for_get = WebAuthn::Credential.options_for_get( + allow: user.webauthn_credentials.pluck(:external_id) + ) + + session[:webauthn_challenge] = options_for_get.challenge + + render json: options_for_get, status: :ok + else + render json: { error: t('webauthn_credentials.not_enabled') }, status: :unauthorized + end + end + protected def find_user @@ -53,7 +69,7 @@ class Auth::SessionsController < Devise::SessionsController end def user_params - params.require(:user).permit(:email, :password, :otp_attempt, :sign_in_token_attempt) + params.require(:user).permit(:email, :password, :otp_attempt, :sign_in_token_attempt, credential: {}) end def after_sign_in_path_for(resource) |