@@ -93,6 +93,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
9393 const userName = adminUser . dbUser [ adminforth . config . auth . usernameField ]
9494 const brandName = adminforth . config . customization . brandName ;
9595 const brandNameSlug = adminforth . config . customization . brandNameSlug ;
96+ const issuerName = ( this . options . customBrendPrefix && this . options . customBrendPrefix . trim ( ) )
97+ ? this . options . customBrendPrefix . trim ( )
98+ : brandName ;
9699 const authResource = adminforth . config . resources . find ( ( res ) => res . resourceId === adminforth . config . auth . usersResourceId )
97100 const authPk = authResource . columns . find ( ( col ) => col . primaryKey ) . name
98101 const userPk = adminUser . dbUser [ authPk ]
@@ -108,10 +111,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
108111 const userCanSkipSetup = this . options . usersFilterToAllowSkipSetup ? this . options . usersFilterToAllowSkipSetup ( adminUser ) : false ;
109112
110113 if ( ! secret ) {
111- const tempSecret = twofactor . generateSecret ( { name : brandName , account : userName } )
114+ const tempSecret = twofactor . generateSecret ( { name : issuerName , account : userName } )
112115 newSecret = tempSecret . secret
113116 } else {
114- const value = this . adminforth . auth . issueJWT ( { userName, issuer :brandName , pk :userPk , userCanSkipSetup, rememberMeDays } , 'tempTotp' , '2h' ) ;
117+ const value = this . adminforth . auth . issueJWT ( { userName, issuer :issuerName , pk :userPk , userCanSkipSetup, rememberMeDays } , 'tempTotp' , '2h' ) ;
115118 response . setHeader ( 'Set-Cookie' , `adminforth_${ brandNameSlug } _totpTemporaryJWT=${ value } ; Path=${ this . adminforth . config . baseUrl || '/' } ; HttpOnly; SameSite=Strict; max-age=3600; ` ) ;
116119
117120 return {
@@ -122,7 +125,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
122125 ok : true
123126 }
124127 }
125- const totpTemporaryJWT = this . adminforth . auth . issueJWT ( { userName, newSecret, issuer :brandName , pk :userPk , userCanSkipSetup, rememberMeDays } , 'tempTotp' , '2h' ) ;
128+ const totpTemporaryJWT = this . adminforth . auth . issueJWT ( { userName, newSecret, issuer :issuerName , pk :userPk , userCanSkipSetup, rememberMeDays } , 'tempTotp' , '2h' ) ;
126129 response . setHeader ( 'Set-Cookie' , `adminforth_${ brandNameSlug } _totpTemporaryJWT=${ totpTemporaryJWT } ; Path=${ this . adminforth . config . baseUrl || '/' } ; HttpOnly; SameSite=Strict; Expires=${ new Date ( Date . now ( ) + '1h' ) . toUTCString ( ) } ` ) ;
127130
128131 return {
0 commit comments