Updated request timeout

ref #154
This commit is contained in:
Nicolai Ort 2021-03-06 13:24:43 +01:00
parent d7099717c2
commit ffcd45e572

View File

@ -61,13 +61,18 @@ export class RunnerSelfServiceController {
@OpenAPI({ description: 'TODO' }) @OpenAPI({ description: 'TODO' })
async requestNewToken(@QueryParam('mail') mail: string) { async requestNewToken(@QueryParam('mail') mail: string) {
const runner = await this.runnerRepository.findOne({ email: mail }); const runner = await this.runnerRepository.findOne({ email: mail });
if (runner.resetRequestedTimestamp > (Math.floor(Date.now() / 1000) - 15 * 60)) { throw new Error("timeout!") } if (runner.resetRequestedTimestamp > (Math.floor(Date.now() / 1000) - 60 * 60 * 24)) { throw new Error("timeout!") }
const token = JwtCreator.createSelfService(runner); const token = JwtCreator.createSelfService(runner);
try { try {
//await Mailer.sendForgottenMail(); //await Mailer.sendForgottenMail();
} catch (error) { } catch (error) {
throw new Error("Mail fucked up"); throw new Error("Mail fucked up");
} }
runner.resetRequestedTimestamp = Math.floor(Date.now() / 1000);
await this.runnerRepository.save(runner);
return { token }; return { token };
} }