fixes
This commit is contained in:
parent
42dbf9736e
commit
8cff63a0a7
@ -47,12 +47,14 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
border-bottom: 1px solid var(--main-darker);
|
border-bottom: 1px solid var(--main-darker);
|
||||||
|
font-size: 1.5rem;
|
||||||
|
|
||||||
&-button .btn {
|
&-button .btn {
|
||||||
min-width: initial;
|
min-width: initial;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
padding: 0 0.65rem;
|
padding: 0 0.65rem;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,11 @@ async function bootstrap() {
|
|||||||
// app.use(express.urlencoded());
|
// app.use(express.urlencoded());
|
||||||
// app.use(cookieParser());
|
// app.use(cookieParser());
|
||||||
|
|
||||||
|
// Production servers have to be behind a proxy.
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
app.set('trust proxy');
|
||||||
|
}
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
session({
|
session({
|
||||||
secret: process.env.SESSION_SECRET,
|
secret: process.env.SESSION_SECRET,
|
||||||
|
@ -52,6 +52,10 @@ export class AccessTokenAdapter implements OAuth2AccessTokenAdapter {
|
|||||||
OAuth2TokenType.ACCESS_TOKEN,
|
OAuth2TokenType.ACCESS_TOKEN,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!find) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...find,
|
...find,
|
||||||
client_id: find.client.client_id,
|
client_id: find.client.client_id,
|
||||||
|
@ -11,6 +11,11 @@ export class ClientAdapter implements OAuth2ClientAdapter {
|
|||||||
|
|
||||||
async fetchById(id: string): Promise<OAuth2Client> {
|
async fetchById(id: string): Promise<OAuth2Client> {
|
||||||
const find = await this._service.clientService.getById(id);
|
const find = await this._service.clientService.getById(id);
|
||||||
|
|
||||||
|
if (!find) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: find.client_id,
|
id: find.client_id,
|
||||||
scope: this._service.splitScope(find.scope),
|
scope: this._service.splitScope(find.scope),
|
||||||
|
@ -43,6 +43,10 @@ export class CodeAdapter implements OAuth2CodeAdapter {
|
|||||||
OAuth2TokenType.CODE,
|
OAuth2TokenType.CODE,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!find) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...find,
|
...find,
|
||||||
code: find.token,
|
code: find.token,
|
||||||
|
@ -47,6 +47,10 @@ export class RefreshTokenAdapter implements OAuth2RefreshTokenAdapter {
|
|||||||
OAuth2TokenType.REFRESH_TOKEN,
|
OAuth2TokenType.REFRESH_TOKEN,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!find) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...find,
|
...find,
|
||||||
client_id: find.client.client_id,
|
client_id: find.client.client_id,
|
||||||
|
@ -13,6 +13,11 @@ export class UserAdapter implements OAuth2UserAdapter {
|
|||||||
|
|
||||||
async fetchById(id: number): Promise<OAuth2User> {
|
async fetchById(id: number): Promise<OAuth2User> {
|
||||||
const find = await this._service.userService.getById(id);
|
const find = await this._service.userService.getById(id);
|
||||||
|
|
||||||
|
if (!find) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: find.id,
|
id: find.id,
|
||||||
username: find.username,
|
username: find.username,
|
||||||
@ -22,6 +27,11 @@ export class UserAdapter implements OAuth2UserAdapter {
|
|||||||
|
|
||||||
async fetchByUsername(username: string): Promise<OAuth2User> {
|
async fetchByUsername(username: string): Promise<OAuth2User> {
|
||||||
const find = await this._service.userService.getByUsername(username);
|
const find = await this._service.userService.getByUsername(username);
|
||||||
|
|
||||||
|
if (!find) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: find.id,
|
id: find.id,
|
||||||
username: find.username,
|
username: find.username,
|
||||||
|
@ -89,31 +89,32 @@ export class SettingsController {
|
|||||||
@Req() req: Request,
|
@Req() req: Request,
|
||||||
@UploadedFile() file: Express.Multer.File,
|
@UploadedFile() file: Express.Multer.File,
|
||||||
) {
|
) {
|
||||||
if (!this._token.verifyCSRF(req)) {
|
|
||||||
throw new BadRequestException('Invalid session. Please try again.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file) {
|
|
||||||
throw new BadRequestException('Avatar upload failed');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!this._token.verifyCSRF(req)) {
|
||||||
|
throw new BadRequestException('Invalid session. Please try again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
throw new BadRequestException('Avatar upload failed');
|
||||||
|
}
|
||||||
|
|
||||||
const matches = await this._upload.checkImageAspect(file);
|
const matches = await this._upload.checkImageAspect(file);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
'Avatar should be with a 1:1 aspect ratio.',
|
'Avatar should be with a 1:1 aspect ratio.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const upload = await this._upload.registerUploadedFile(file, req.user);
|
||||||
|
await this._user.updateAvatar(req.user, upload);
|
||||||
|
|
||||||
|
return {
|
||||||
|
file: upload.file,
|
||||||
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await unlink(file.path);
|
await unlink(file.path);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
const upload = await this._upload.registerUploadedFile(file, req.user);
|
|
||||||
await this._user.updateAvatar(req.user, upload);
|
|
||||||
return {
|
|
||||||
file: upload.file,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('avatar/delete')
|
@Post('avatar/delete')
|
||||||
|
Reference in New Issue
Block a user