mirror of
https://github.com/we-promise/sure.git
synced 2026-05-08 05:04:59 +00:00
feat(auth): add WebAuthn MFA credentials (#1628)
* feat(auth): add WebAuthn MFA credentials * fix(auth): harden WebAuthn MFA review paths * fix(auth): polish WebAuthn error handling * fix(auth): handle duplicate WebAuthn credential races * fix(auth): permit WebAuthn credential params * fix(auth): trim WebAuthn registration controller cleanup * fix(auth): tighten WebAuthn MFA handling * fix(auth): pin WebAuthn relying party config
This commit is contained in:
39
app/javascript/controllers/webauthn_controller.js
Normal file
39
app/javascript/controllers/webauthn_controller.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
get headers() {
|
||||
return {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": document.querySelector("meta[name='csrf-token']")
|
||||
?.content,
|
||||
};
|
||||
}
|
||||
|
||||
async errorMessage(response) {
|
||||
try {
|
||||
const result = await response.clone().json();
|
||||
if (result.error) return result.error;
|
||||
} catch (_error) {
|
||||
return this.errorFallbackValue;
|
||||
}
|
||||
|
||||
return this.errorFallbackValue;
|
||||
}
|
||||
|
||||
showError(message) {
|
||||
if (this.hasErrorTarget) {
|
||||
this.errorTarget.textContent = message;
|
||||
this.errorTarget.hidden = false;
|
||||
this.errorTarget.setAttribute("aria-hidden", "false");
|
||||
}
|
||||
}
|
||||
|
||||
clearError() {
|
||||
if (this.hasErrorTarget) {
|
||||
this.errorTarget.textContent = "";
|
||||
this.errorTarget.hidden = true;
|
||||
this.errorTarget.setAttribute("aria-hidden", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user