From 2ca6dcfae81011e0c019846b7ff00708e2ddb032 Mon Sep 17 00:00:00 2001 From: Alexandros SIDIRAS Date: Fri, 15 Mar 2024 11:24:53 +0100 Subject: [PATCH] fix signup --- src/auth/auth.controller.ts | 10 ++++++++-- src/auth/user.repository.ts | 5 +++++ src/collection/collection.repository.ts | 8 ++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 388e7e1..c38ae60 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -24,7 +24,7 @@ import { modifyCollectionDto } from 'src/collection/dto/collection.modify.dto'; import { UserGuard } from './user.guard'; import { GetUser } from './get-user.decorator'; import { AuthenticatedUser } from 'nest-keycloak-connect'; -@UseGuards(UserGuard) + @Controller('') export class AuthController { private logger = new Logger('AuthController'); @@ -100,12 +100,14 @@ export class AuthController { return; } + @UseGuards(UserGuard) @Get('user/details') getUserDetails(@GetUser() user: User): Promise { this.logger.verbose(`User "${user.username}" is trying to get Details`); return this.authService.getUserDetails(user); } + @UseGuards(UserGuard) @Put('user/details') async editUser( @GetUser() user: User, @@ -146,14 +148,15 @@ export class AuthController { return editedUser; } + @UseGuards(UserGuard) @Get('/user/root') - async getRoot(@GetUser() user: User): Promise { this.logger.verbose(`User "${user.username}" getting his root`); const root = await this.authService.getRoot(user); return this.collectionService.getCollectionById(root, user); } + @UseGuards(UserGuard) @Get('/user/sider') async getSider(@GetUser() user: User): Promise { this.logger.verbose(`User "${user.username}" getting his root`); @@ -161,6 +164,7 @@ export class AuthController { return this.collectionService.getCollectionById(sider, user); } + @UseGuards(UserGuard) @Get('/user/shared') async getShared(@GetUser() user: User): Promise { this.logger.verbose( @@ -170,11 +174,13 @@ export class AuthController { return this.collectionService.getCollectionById(shared, user); } + @UseGuards(UserGuard) @Get('/user/notification') async getNotifications(@GetUser() user: User): Promise { return this.authService.getNotifications(user); } + @UseGuards(UserGuard) @Delete('/user/notification') async clearNotifications(@GetUser() user: User): Promise { this.logger.verbose(`User "${user.username}" clearing his notifications`); diff --git a/src/auth/user.repository.ts b/src/auth/user.repository.ts index 15d27d4..f1285d3 100644 --- a/src/auth/user.repository.ts +++ b/src/auth/user.repository.ts @@ -27,6 +27,11 @@ export class UserRepository extends Repository { user.username = username; user.language = language; user.displayLanguage = displayLanguage; + user.password = 'not_used'; + user.salt = 'salt'; + user.resetPasswordToken = ''; + user.resetPasswordExpires = ''; + user.validationToken = 'verified'; const voices = validLanguage(languages); user.languages = stringifyMap(voices); if (directSharers) { diff --git a/src/collection/collection.repository.ts b/src/collection/collection.repository.ts index 769ee2c..ee0aaa4 100644 --- a/src/collection/collection.repository.ts +++ b/src/collection/collection.repository.ts @@ -207,8 +207,8 @@ export class CollectionRepository extends Repository { async createShared(user: User): Promise { if (user.shared === null) { const shared = new Collection(); - shared.meaning = ''; - shared.speech = ''; + shared.meaning = {}; + shared.speech = {}; shared.userId = user.id; try { await shared.save(); @@ -232,8 +232,8 @@ export class CollectionRepository extends Repository { async createSider(user: User): Promise { if (user.sider === null) { const sider = new Collection(); - sider.meaning = ''; - sider.speech = ''; + sider.meaning = {}; + sider.speech = {}; sider.userId = user.id; try { await sider.save();