import { Component } from '../../lib/vues6/vues6.js' import { location_service } from '../service/Location.service.js' import { auth_api } from '../service/AuthApi.service.js' const template = `
{{ app_name }}
To recover access to your account, you can enter one of the generated MFA recovery codes:
{{ error_message }}
{{ other_message }}
Have a normal MFA code?
` export default class MFARecoveryComponent extends Component { static get selector() { return 'coreid-mfa-recovery-page' } static get template() { return template } static get props() { return ['app_name'] } verify_success = false loading = false recovery_code = '' error_message = '' other_message = '' async vue_on_create() { this.$nextTick(() => { this.$refs.verify_input.focus() }) } async on_key_up($event) { if ( this.recovery_code.length === 36 ) { this.error_message = '' this.other_message = '' this.loading = true const result = await auth_api.attempt_mfa_recovery(this.recovery_code) if ( result && result.success ) { this.other_message = `Success! There are only ${result.remaining_codes} recovery codes remaining. Let's get you on your way...` await location_service.redirect(result.next_destination, 5000) } else { this.loading = false this.error_message = 'Hm. It doesn\'t look like that code is valid.' } } } async on_do_challenge() { await location_service.redirect('/auth/mfa/challenge', 0) } }