Updated request timeout

ref #154
This commit is contained in:
Nicolai Ort 2021-03-06 13:24:43 +01:00
parent d7099717c2
commit ffcd45e572
1 changed files with 6 additions and 1 deletions

View File

@ -61,13 +61,18 @@ export class RunnerSelfServiceController {
@OpenAPI({ description: 'TODO' })
async requestNewToken(@QueryParam('mail') mail: string) {
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);
try {
//await Mailer.sendForgottenMail();
} catch (error) {
throw new Error("Mail fucked up");
}
runner.resetRequestedTimestamp = Math.floor(Date.now() / 1000);
await this.runnerRepository.save(runner);
return { token };
}