Clean up tokens
This commit is contained in:
parent
94747cfe7e
commit
4ebbedf4bc
|
@ -1026,6 +1026,15 @@ function getDefaultConfig() {
|
||||||
args : [ '24 hours' ] // items older than this will be removed
|
args : [ '24 hours' ] // items older than this will be removed
|
||||||
},
|
},
|
||||||
|
|
||||||
|
twoFactorRegisterTokenMaintenance : {
|
||||||
|
schedule : 'every 24 hours',
|
||||||
|
action : '@method:core/user_temp_token.js:temporaryTokenMaintenanceTask',
|
||||||
|
args : [
|
||||||
|
'auth_factor2_otp_register',
|
||||||
|
'24 hours', // expire time
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
// Enable the following entry in your config.hjson to periodically create/update
|
// Enable the following entry in your config.hjson to periodically create/update
|
||||||
// DESCRIPT.ION files for your file base
|
// DESCRIPT.ION files for your file base
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
// ENiGMA½
|
// ENiGMA½
|
||||||
const Config = require('./config.js').get;
|
const Config = require('./config.js').get;
|
||||||
const Errors = require('./enig_error.js').Errors;
|
|
||||||
const getServer = require('./listening_server.js').getServer;
|
const getServer = require('./listening_server.js').getServer;
|
||||||
const webServerPackageName = require('./servers/content/web.js').moduleInfo.packageName;
|
const webServerPackageName = require('./servers/content/web.js').moduleInfo.packageName;
|
||||||
const {
|
const {
|
||||||
createToken,
|
createToken,
|
||||||
|
deleteToken,
|
||||||
getTokenInfo,
|
getTokenInfo,
|
||||||
WellKnownTokenTypes,
|
WellKnownTokenTypes,
|
||||||
} = require('./user_temp_token.js');
|
} = require('./user_temp_token.js');
|
||||||
|
@ -145,7 +145,7 @@ module.exports = class User2FA_OTPWebRegister
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tokenInfo.tokenType !== 'auth_factor2_otp_register') {
|
if(tokenInfo.tokenType !== WellKnownTokenTypes.AuthFactor2OTPRegister) {
|
||||||
return User2FA_OTPWebRegister.accessDenied(webServer, resp);
|
return User2FA_OTPWebRegister.accessDenied(webServer, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ module.exports = class User2FA_OTPWebRegister
|
||||||
|
|
||||||
prepareOTP(otpType, prepareOptions, (err, otpInfo) => {
|
prepareOTP(otpType, prepareOptions, (err, otpInfo) => {
|
||||||
if(err) {
|
if(err) {
|
||||||
// :TODO: Log error
|
Log.error({ error : err.message }, 'Failed to prepare OTP');
|
||||||
return User2FA_OTPWebRegister.accessDenied(webServer, resp);
|
return User2FA_OTPWebRegister.accessDenied(webServer, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,13 @@ module.exports = class User2FA_OTPWebRegister
|
||||||
if(err) {
|
if(err) {
|
||||||
return webServer.instance.respondWithError(resp, 500, 'Internal Server Error', 'Internal Server Error');
|
return webServer.instance.respondWithError(resp, 500, 'Internal Server Error', 'Internal Server Error');
|
||||||
}
|
}
|
||||||
// :TODO: remove token
|
|
||||||
|
// we can now remove the token - no need to wait
|
||||||
|
deleteToken(formData.token, err => {
|
||||||
|
if(err) {
|
||||||
|
Log.error({error : err.message, token : formData.token}, 'Failed to delete temporary token');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// :TODO: use a html template here too, if provided
|
// :TODO: use a html template here too, if provided
|
||||||
resp.writeHead(200);
|
resp.writeHead(200);
|
||||||
|
|
Loading…
Reference in New Issue