@@ -30,7 +30,12 @@ function wrongPassword(isError = false, isSuccess = false, data = null) {
30
30
$ ( "#error-message" ) . text ( "" ) ;
31
31
$ ( "#error-hint" ) . hide ( ) ;
32
32
$ ( "#error-hint" ) . text ( "" ) ;
33
- if ( data !== null && "error" in data . responseJSON && "message" in data . responseJSON . error ) {
33
+ if (
34
+ data !== null &&
35
+ "responseJSON" in data &&
36
+ "error" in data . responseJSON &&
37
+ "message" in data . responseJSON . error
38
+ ) {
34
39
// This is an error, highlight both the password and the TOTP field
35
40
isErrorResponse = true ;
36
41
// Check if the error is caused by an invalid TOTP token
@@ -168,13 +173,15 @@ $(function () {
168
173
if ( data . session . valid === true ) redirect ( ) ;
169
174
} )
170
175
. fail ( function ( xhr ) {
171
- const session = xhr . responseJSON . session ;
172
- // If TOPT is enabled, show the input field and add the required attribute
173
- if ( session . totp === true ) {
174
- $ ( "#totp_input" ) . removeClass ( "hidden" ) ;
175
- $ ( "#totp" ) . attr ( "required" , "required" ) ;
176
- $ ( "#totp-forgotten-title" ) . removeClass ( "hidden" ) ;
177
- $ ( "#totp-forgotten-body" ) . removeClass ( "hidden" ) ;
176
+ if ( "responseJSON" in xhr ) {
177
+ const session = xhr . responseJSON . session ;
178
+ // If TOPT is enabled, show the input field and add the required attribute
179
+ if ( session . totp === true ) {
180
+ $ ( "#totp_input" ) . removeClass ( "hidden" ) ;
181
+ $ ( "#totp" ) . attr ( "required" , "required" ) ;
182
+ $ ( "#totp-forgotten-title" ) . removeClass ( "hidden" ) ;
183
+ $ ( "#totp-forgotten-body" ) . removeClass ( "hidden" ) ;
184
+ }
178
185
}
179
186
} ) ;
180
187
0 commit comments