Skip to content

Commit fd09434

Browse files
committed
Merge branch 'develop' into feature/login-stats
2 parents c35cf81 + 5c152ec commit fd09434

File tree

24 files changed

+228
-68
lines changed

24 files changed

+228
-68
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Apply blank line linting rules
22
2bbe554f470c5b7a0d59927dd3b9783314a0d805
3+
4+
# Linting commits
5+
6efc953b9f7f648f2be59295a78ce1180f12b32d

NoteBlockWorld.code-workspace

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
}
1919
],
2020
"settings": {
21+
"editor.formatOnSave": true,
22+
"eslint.validate": ["typescript"],
23+
"eslint.run": "onType",
24+
"eslint.format.enable": true,
2125
"mdx.server.enable": true,
26+
"editor.codeActionsOnSave": {
27+
"source.fixAll": "explicit"
28+
},
2229
"jest.disabledWorkspaceFolders": ["Root", "Frontend"]
2330
}
2431
}

pnpm-lock.yaml

Lines changed: 4 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/auth/auth.module.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ export class AuthModule {
6262
useFactory: (configService: ConfigService) =>
6363
configService.getOrThrow<string>('SERVER_URL'),
6464
},
65-
{
66-
inject: [ConfigService],
67-
provide: 'MAGIC_LINK_SECRET',
68-
useFactory: (configService: ConfigService) =>
69-
configService.getOrThrow<string>('MAGIC_LINK_SECRET'),
70-
},
7165
{
7266
inject: [ConfigService],
7367
provide: 'FRONTEND_URL',

server/src/user/dto/user.dto.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { User } from '../entity/user.entity';
2+
3+
export class UserDto {
4+
username: string;
5+
publicName: string;
6+
email: string;
7+
static fromEntity(user: User): UserDto {
8+
const userDto: UserDto = {
9+
username: user.username,
10+
publicName: user.publicName,
11+
email: user.email,
12+
};
13+
14+
return userDto;
15+
}
16+
}

server/src/user/user.service.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,12 @@ describe('UserService', () => {
404404

405405
const result = await service.updateUsername(user, body);
406406

407-
expect(result).toEqual(user);
407+
expect(result).toEqual({
408+
username: 'newuser',
409+
publicName: undefined,
410+
email: undefined,
411+
});
412+
408413
expect(user.username).toBe(body.username);
409414
expect(service.usernameExists).toHaveBeenCalledWith(body.username);
410415
});

server/src/user/user.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { UpdateUsernameDto } from '@shared/validation/user/dto/UpdateUsername.dt
77
import { validate } from 'class-validator';
88
import { Model } from 'mongoose';
99

10+
import { UserDto } from './dto/user.dto';
1011
import { User, UserDocument } from './entity/user.entity';
1112

1213
@Injectable()
@@ -167,7 +168,10 @@ export class UserService {
167168
}
168169

169170
user.username = username;
171+
user.lastEdited = new Date();
170172

171-
return await user.save();
173+
await user.save();
174+
175+
return UserDto.fromEntity(user);
172176
}
173177
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { deepFreeze } from '../common/deepFreeze';
2+
3+
export const UserConst = deepFreeze({
4+
USERNAME_MIN_LENGTH: 3,
5+
USERNAME_MAX_LENGTH: 32,
6+
ALLOWED_REGEXP: /^[a-zA-Z0-9-_.]*$/,
7+
});

shared/validation/user/dto/UpdateUsername.dto.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { ApiProperty } from '@nestjs/swagger';
2-
import { IsString, IsNotEmpty, MinLength, MaxLength } from 'class-validator';
2+
import { IsString, Matches, MaxLength, MinLength } from 'class-validator';
3+
4+
import { UserConst } from '../constants';
35

46
export class UpdateUsernameDto {
57
@IsString()
6-
@MaxLength(64)
7-
@MinLength(3)
8+
@MaxLength(UserConst.USERNAME_MAX_LENGTH)
9+
@MinLength(UserConst.USERNAME_MIN_LENGTH)
10+
@Matches(UserConst.ALLOWED_REGEXP)
811
@ApiProperty({
912
description: 'Username of the user',
1013
example: 'tomast1137',

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"tailwindcss": "3.4.1",
5454
"tailwindcss-animate": "^1.0.7",
5555
"typescript": "^5.1.3",
56-
"zod": "^3.22.4",
57-
"zod-validation-error": "^3.0.0"
56+
"zod": "^3.24.1",
57+
"zod-validation-error": "^3.4.0"
5858
},
5959
"devDependencies": {
6060
"@shrutibalasa/tailwind-grid-auto-fit": "^1.1.0",

0 commit comments

Comments
 (0)