@@ -1023,21 +1023,15 @@ module.exports = (
10231023 handler : async function ( request ) {
10241024 log . begin ( 'totp.replace.create' , request ) ;
10251025
1026- const { uid } = request . auth . credentials ;
1027- const account = await db . account ( uid ) ;
1026+ const { uid, email } = request . auth . credentials ;
10281027
10291028 const { tokenVerified, tokenVerificationId } =
10301029 request . auth . credentials || { } ;
10311030 if ( tokenVerificationId || tokenVerified === false ) {
10321031 throw errors . unverifiedSession ( ) ;
10331032 }
10341033
1035- await customs . checkAuthenticated (
1036- request ,
1037- uid ,
1038- account . email ,
1039- 'totpCreate'
1040- ) ;
1034+ await customs . checkAuthenticated ( request , uid , email , 'totpCreate' ) ;
10411035
10421036 // the opposite of `/totp/create` this requires that the user already has
10431037 // a verified TOTP token to be replaced.
@@ -1082,7 +1076,7 @@ module.exports = (
10821076 log . info ( 'totpToken.replace.created' , { uid } ) ;
10831077 await request . emitMetricsEvent ( 'totpToken.replace.created' , { uid } ) ;
10841078
1085- const otpauth = authenticator . keyuri ( account . email , service , secret ) ;
1079+ const otpauth = authenticator . keyuri ( email , service , secret ) ;
10861080
10871081 const qrCodeUrl = await qrcode . toDataURL ( otpauth , qrCodeOptions ) ;
10881082
@@ -1152,21 +1146,15 @@ module.exports = (
11521146 log . begin ( 'totp.replace.confirm' , request ) ;
11531147
11541148 const code = request . payload . code ;
1155- const { uid } = request . auth . credentials ;
1156- const account = await db . account ( uid ) ;
1149+ const { uid, email } = request . auth . credentials ;
11571150
11581151 const { tokenVerified, tokenVerificationId } =
11591152 request . auth . credentials || { } ;
11601153 if ( tokenVerificationId || tokenVerified === false ) {
11611154 throw errors . unverifiedSession ( ) ;
11621155 }
11631156
1164- await customs . checkAuthenticated (
1165- request ,
1166- uid ,
1167- account . email ,
1168- 'totpReplace'
1169- ) ;
1157+ await customs . checkAuthenticated ( request , uid , email , 'totpReplace' ) ;
11701158 // check the redis cache for the NEW secret. Since the existing code
11711159 // is verified and stored in the db we must use the redis cache
11721160 const newSharedSecret = await authServerCacheRedis . get (
0 commit comments