@@ -100,6 +100,7 @@ let selectedMultiFactorHint = null;
100
100
let recaptchaSize = 'normal' ;
101
101
let webWorker = null ;
102
102
let totpSecret = null ;
103
+ let totpDeadlineId = null ;
103
104
104
105
// The corresponding Font Awesome icons for each provider.
105
106
const providersIcons = {
@@ -715,11 +716,11 @@ async function onStartEnrollWithTotpMultiFactor() {
715
716
) ;
716
717
// display the numbr of seconds left to enroll.
717
718
$ ( 'p.totp-deadline' ) . show ( ) ;
718
- var id = setInterval ( function ( ) {
719
+ totpDeadlineId = setInterval ( function ( ) {
719
720
var deadline = new Date ( totpSecret . enrollmentCompletionDeadline ) ;
720
721
var t = deadline - new Date ( ) . getTime ( ) ;
721
722
if ( t < 0 ) {
722
- clearInterval ( id ) ;
723
+ clearInterval ( totpDeadlineId ) ;
723
724
document . getElementById ( 'totp-deadline' ) . innerText =
724
725
'TOTP enrollment expired!' ;
725
726
} else {
@@ -756,12 +757,21 @@ async function onFinalizeEnrollWithTotpMultiFactor() {
756
757
try {
757
758
await multiFactor ( activeUser ( ) ) . enroll ( multiFactorAssertion , displayName ) ;
758
759
refreshUserData ( ) ;
760
+ clearTOTPUIState ( ) ;
759
761
alertSuccess ( 'TOTP MFA enrolled!' ) ;
760
762
} catch ( e ) {
761
763
onAuthError ( e ) ;
762
764
}
763
765
}
764
766
767
+ function clearTOTPUIState ( ) {
768
+ $ ( 'p.totp-deadline' ) . hide ( ) ;
769
+ $ ( 'img.totp-qr-image' ) . hide ( ) ;
770
+ $ ( 'p.totp-text' ) . hide ( ) ;
771
+ $ ( 'enroll-mfa-totp-verification-code' ) . hide ( ) ;
772
+ $ ( 'enroll-mfa-totp-display-name' ) . hide ( ) ;
773
+ clearInterval ( totpDeadlineId ) ;
774
+ }
765
775
/**
766
776
* Signs in or links a provider's credential, based on current tab opened.
767
777
* @param {!AuthCredential } credential The provider's credential.
0 commit comments