From d46ad5954676e73ab3c77f2d84c87b22088f4e71 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sat, 5 Dec 2020 11:14:26 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20CreateAuth=20now=20returns=20a?= =?UTF-8?q?=20sample=20jwt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref #12 --- src/models/creation/CreateAuth.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/models/creation/CreateAuth.ts b/src/models/creation/CreateAuth.ts index a1a8884..b2c9727 100644 --- a/src/models/creation/CreateAuth.ts +++ b/src/models/creation/CreateAuth.ts @@ -12,6 +12,7 @@ export class CreateAuth { username?: string; @IsString() password: string; + @IsOptional() @IsEmail() @IsString() email?: string; @@ -26,20 +27,17 @@ export class CreateAuth { throw new PasswordNeededError() } const found_users = await getConnectionManager().get().getRepository(User).find({ where: [{ username: this.username }, { email: this.email }] }); - console.log(found_users); if (found_users.length === 0) { throw new UserNotFoundError() } else { const found_user = found_users[0] - const token = jsonwebtoken.sign(found_user, "sec") - - // TODO: jwt creation + // TODO: proper jwt creation + const token = jsonwebtoken.sign({}, "securekey") newAuth.access_token = token newAuth.refresh_token = token newAuth.access_token_expires_at = 1587349200 newAuth.refresh_token_expires_at = 1587349200 - console.log(newAuth) } return newAuth; }