@@ -34,7 +34,8 @@ module.exports = (log, db, config, customs, mailer, glean, statsd) => {
3434 options : {
3535 ...RECOVERY_CODES_DOCS . RECOVERYCODES_GET ,
3636 auth : {
37- strategy : 'sessionToken' ,
37+ strategy : 'verifiedSessionToken' ,
38+ payload : false ,
3839 } ,
3940 response : {
4041 schema : recoveryCodesSchema ,
@@ -88,7 +89,8 @@ module.exports = (log, db, config, customs, mailer, glean, statsd) => {
8889 options : {
8990 ...RECOVERY_CODES_DOCS . RECOVERY_CODES_POST ,
9091 auth : {
91- strategy : 'sessionToken' ,
92+ strategy : 'verifiedSessionToken' ,
93+ payload : false ,
9294 } ,
9395 validate : {
9496 payload : recoveryCodesSchema ,
@@ -108,13 +110,11 @@ module.exports = (log, db, config, customs, mailer, glean, statsd) => {
108110 // no previous backup codes should be in the database
109111 // the session should not yet have a higher assurance level
110112 const account = await db . account ( uid ) ;
111- const { hasBackupCodes } =
112- await backupCodeManager . getCountForUserId ( uid ) ;
113113 const hasTotpToken = await otpUtils . hasTotpToken ( { uid } ) ;
114114 // for initial setup, only fail if totp is already enabled
115115 // if totp is not enabled/verified, it is safe to replace the recovery codes
116- if ( hasBackupCodes && hasTotpToken ) {
117- throw errors . recoveryCodesAlreadyExist ( ) ;
116+ if ( hasTotpToken ) {
117+ throw errors . totpTokenAlreadyExists ( ) ;
118118 }
119119
120120 const { recoveryCodes } = request . payload ;
@@ -143,7 +143,8 @@ module.exports = (log, db, config, customs, mailer, glean, statsd) => {
143143 options : {
144144 ...RECOVERY_CODES_DOCS . RECOVERY_CODES_PUT ,
145145 auth : {
146- strategy : 'sessionToken' ,
146+ strategy : 'verifiedSessionToken' ,
147+ payload : false ,
147148 } ,
148149 validate : {
149150 payload : recoveryCodesSchema ,
0 commit comments