Skip to content

Commit

Permalink
fix signup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratatinator97 committed Mar 15, 2024
1 parent dd40a74 commit 2ca6dcf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -100,12 +100,14 @@ export class AuthController {
return;
}

@UseGuards(UserGuard)
@Get('user/details')
getUserDetails(@GetUser() user: User): Promise<User> {
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,
Expand Down Expand Up @@ -146,21 +148,23 @@ export class AuthController {
return editedUser;
}

@UseGuards(UserGuard)
@Get('/user/root')

async getRoot(@GetUser() user: User): Promise<Collection> {
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<Collection> {
this.logger.verbose(`User "${user.username}" getting his root`);
const sider = await this.authService.getSider(user);
return this.collectionService.getCollectionById(sider, user);
}

@UseGuards(UserGuard)
@Get('/user/shared')
async getShared(@GetUser() user: User): Promise<Collection> {
this.logger.verbose(
Expand All @@ -170,11 +174,13 @@ export class AuthController {
return this.collectionService.getCollectionById(shared, user);
}

@UseGuards(UserGuard)
@Get('/user/notification')
async getNotifications(@GetUser() user: User): Promise<Notif[]> {
return this.authService.getNotifications(user);
}

@UseGuards(UserGuard)
@Delete('/user/notification')
async clearNotifications(@GetUser() user: User): Promise<Notif[]> {
this.logger.verbose(`User "${user.username}" clearing his notifications`);
Expand Down
5 changes: 5 additions & 0 deletions src/auth/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export class UserRepository extends Repository<User> {
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) {
Expand Down
8 changes: 4 additions & 4 deletions src/collection/collection.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ export class CollectionRepository extends Repository<Collection> {
async createShared(user: User): Promise<number> {
if (user.shared === null) {
const shared = new Collection();
shared.meaning = '';
shared.speech = '';
shared.meaning = {};
shared.speech = {};
shared.userId = user.id;
try {
await shared.save();
Expand All @@ -232,8 +232,8 @@ export class CollectionRepository extends Repository<Collection> {
async createSider(user: User): Promise<number> {
if (user.sider === null) {
const sider = new Collection();
sider.meaning = '';
sider.speech = '';
sider.meaning = {};
sider.speech = {};
sider.userId = user.id;
try {
await sider.save();
Expand Down

0 comments on commit 2ca6dcf

Please sign in to comment.