From 146787fd660afe1bd8d775b9355e3ad97f6795dc Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 22 Dec 2020 11:48:06 +0100 Subject: [PATCH] Added comments ref #40 --- src/controllers/AuthController.ts | 1 + src/models/actions/CreateResetToken.ts | 6 ++++-- src/models/actions/ResetPassword.ts | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/controllers/AuthController.ts b/src/controllers/AuthController.ts index a141a6c..98a9f85 100644 --- a/src/controllers/AuthController.ts +++ b/src/controllers/AuthController.ts @@ -87,6 +87,7 @@ export class AuthController { @ResponseSchema(UsernameOrEmailNeededError) @OpenAPI({ description: "Request a password reset token" }) async getResetToken(@Body({ validate: true }) passwordReset: CreateResetToken) { + //This really shouldn't just get returned, but sent via mail or sth like that. But for dev only this is fine. return { "resetToken": await passwordReset.toResetToken() }; } diff --git a/src/models/actions/CreateResetToken.ts b/src/models/actions/CreateResetToken.ts index 8e63b24..dcf22f1 100644 --- a/src/models/actions/CreateResetToken.ts +++ b/src/models/actions/CreateResetToken.ts @@ -6,7 +6,8 @@ import { JwtCreator } from '../../jwtcreator'; import { User } from '../entities/User'; /** - * TODO: + * This calss is used to create password reset tokens for users. + * These password reset token can be used to set a new password for the user for the next 15mins. */ export class CreateResetToken { /** @@ -41,8 +42,9 @@ export class CreateResetToken { found_user.resetRequestedTimestamp = Math.floor(Date.now() / 1000); await getConnectionManager().get().getRepository(User).save(found_user); - //Create the reset + //Create the reset token let reset_token = JwtCreator.createReset(found_user); + return reset_token; } } \ No newline at end of file diff --git a/src/models/actions/ResetPassword.ts b/src/models/actions/ResetPassword.ts index e8229b3..2dafc11 100644 --- a/src/models/actions/ResetPassword.ts +++ b/src/models/actions/ResetPassword.ts @@ -7,7 +7,8 @@ import { IllegalJWTError, JwtNotProvidedError, PasswordNeededError, RefreshToken import { User } from '../entities/User'; /** - * TODO: + * This class can be used to reset a user's password. + * To set a new password the user needs to provide a valid password reset token. */ export class ResetPassword { /**