File tree 5 files changed +26
-11
lines changed
5 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ module.exports = {
30
30
. where ( 'user_id' , userId )
31
31
. first ( )
32
32
. then ( ( auth ) => {
33
+ console . log ( auth ) ;
33
34
if ( ! auth ) {
34
35
throw new error . AuthError ( 'User not found.' ) ;
35
36
}
36
- return auth . mfa_enabled === 1 ;
37
+ return auth . mfa_enabled === true ;
37
38
} ) ;
38
39
} ,
39
40
createMfaSecretForUser : ( userId ) => {
@@ -68,7 +69,7 @@ module.exports = {
68
69
return authModel
69
70
. query ( )
70
71
. where ( 'user_id' , userId )
71
- . update ( { mfa_enabled : 1 } )
72
+ . update ( { mfa_enabled : true } )
72
73
. then ( ( ) => true ) ;
73
74
} ) ;
74
75
} ,
Original file line number Diff line number Diff line change 27
27
</div >
28
28
29
29
<div class =" col-sm-12 col-md-12" >
30
- <button type =" button" class =" btn btn-info add-mfa" >Add MFA</button >
31
- <p class =" qr-instructions" style =" display : none ;" >Scan this QR code in your authenticator app to set up MFA and then enter the current MFA code in the input field.</p >
30
+ <label class =" form-label mfa-label" style =" display : none ;" ><% - i18n (' mfa' , ' mfa' ) %> </label >
31
+ <button type =" button" class =" btn btn-info add-mfa" ><% - i18n (' mfa' , ' add-mfa' ) %> </button >
32
+ <p class =" qr-instructions" style =" display : none ;" ><% - i18n (' mfa' , ' mfa-setup-instruction' ) %> </p >
32
33
<div class =" mfa-validation-container" style =" display : none ;" >
33
- <label class =" form-label" ><% - i18n (' str ' , ' mfa' ) %> <span class =" form-required" >*</span ></label >
34
- <input name =" mfa_validation" type =" text" class =" form-control" placeholder =" 000000" value =" " required >
34
+ <label class =" form-label" ><% - i18n (' mfa ' , ' mfa-token ' ) %> <span class =" form-required" >*</span ></label >
35
+ <input name =" mfa_validation" type =" text" class =" form-control" placeholder =" 000000" value =" " >
35
36
</div >
36
37
</div >
37
38
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ module.exports = Mn.View.extend({
16
16
save : 'button.save' ,
17
17
error : '.secret-error' ,
18
18
addMfa : '.add-mfa' ,
19
+ mfaLabel : '.mfa-label' , // added binding
19
20
mfaValidation : '.mfa-validation-container' , // added binding
20
21
qrInstructions : '.qr-instructions' // added binding for instructions
21
22
} ,
@@ -99,6 +100,8 @@ module.exports = Mn.View.extend({
99
100
view . ui . addMfa . replaceWith ( `<img class="qr-code" src="${ response . qrCode } " alt="QR Code">` ) ;
100
101
view . ui . qrInstructions . show ( ) ;
101
102
view . ui . mfaValidation . show ( ) ;
103
+ // Add required attribute once MFA is activated
104
+ view . ui . mfaValidation . find ( 'input[name="mfa_validation"]' ) . attr ( 'required' , true ) ;
102
105
} )
103
106
. catch ( err => {
104
107
view . ui . error . text ( err . message ) . show ( ) ;
@@ -140,12 +143,17 @@ module.exports = Mn.View.extend({
140
143
. then ( response => {
141
144
if ( response . active ) {
142
145
view . ui . addMfa . hide ( ) ;
146
+ view . ui . mfaLabel . hide ( ) ;
143
147
view . ui . qrInstructions . hide ( ) ;
144
148
view . ui . mfaValidation . hide ( ) ;
149
+ // Remove required attribute if MFA is active & field is hidden
150
+ view . ui . mfaValidation . find ( 'input[name="mfa_validation"]' ) . removeAttr ( 'required' ) ;
145
151
} else {
146
152
view . ui . addMfa . show ( ) ;
153
+ view . ui . mfaLabel . show ( ) ;
147
154
view . ui . qrInstructions . hide ( ) ;
148
155
view . ui . mfaValidation . hide ( ) ;
156
+ view . ui . mfaValidation . find ( 'input[name="mfa_validation"]' ) . removeAttr ( 'required' ) ;
149
157
}
150
158
} )
151
159
. catch ( err => {
Original file line number Diff line number Diff line change 2
2
"en" : {
3
3
"str" : {
4
4
"email-address" : " Email address" ,
5
- "mfa" : " Multi factor authentication token" ,
6
5
"username" : " Username" ,
7
6
"password" : " Password" ,
8
7
"sign-in" : " Sign in" ,
38
37
"all" : " All" ,
39
38
"any" : " Any"
40
39
},
40
+ "mfa" : {
41
+ "mfa" : " Multi Factor Authentication" ,
42
+ "add-mfa" : " Generate secret" ,
43
+ "mfa-setup-instruction" : " Scan this QR code in your authenticator app to set up MFA and then enter the current MFA code in the input field." ,
44
+ "mfa-token" : " Multi factor authentication token"
45
+ },
41
46
"login" : {
42
47
"title" : " Login to your account" ,
43
- "mfa_required_text " : " Please enter your MFA token to continue"
48
+ "mfa-required-text " : " Please enter your MFA token to continue"
44
49
},
45
50
"main" : {
46
51
"app" : " Nginx Proxy Manager" ,
Original file line number Diff line number Diff line change 26
26
<div class =" invalid-feedback secret-error" ></div >
27
27
</div >
28
28
<div class =" form-group mfa-group" style =" display : none ;" >
29
- <p class =" mfa-info" ><% - i18n (' login' , ' mfa_required_text ' ) %> :</p >
30
- <label class =" form-label" ><% - i18n (' str ' , ' mfa' ) %> </label >
31
- <input name =" mfa_token" type =" text" class =" form-control" placeholder =" <%- i18n('str ', 'mfa') %>" >
29
+ <p class =" mfa-info" ><% - i18n (' login' , ' mfa-required-text ' ) %> :</p >
30
+ <label class =" form-label" ><% - i18n (' mfa ' , ' mfa-token ' ) %> </label >
31
+ <input name =" mfa_token" type =" text" class =" form-control" placeholder =" <%- i18n('mfa ', 'mfa-token ') %>" >
32
32
<div class =" invalid-feedback mfa-error" ></div >
33
33
</div >
34
34
<div class =" form-footer" >
You can’t perform that action at this time.
0 commit comments