mirror of
https://github.com/CaramelFur/Picsur.git
synced 2026-02-25 07:30:44 +01:00
Make the "Please Log In" text link to the login page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ArgumentsHost, Catch, ExceptionFilter, Logger } from '@nestjs/common';
|
||||
import { ArgumentsHost, Catch, ExceptionFilter, ForbiddenException, Logger, MethodNotAllowedException, NotFoundException, UnauthorizedException } from '@nestjs/common';
|
||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { ApiErrorResponse } from 'picsur-shared/dist/dto/api/api.dto';
|
||||
import {
|
||||
@@ -24,10 +24,7 @@ export class MainExceptionFilter implements ExceptionFilter {
|
||||
const traceString = `(${request.ip} -> ${request.method} ${request.url})`;
|
||||
|
||||
if (!IsFailure(exception)) {
|
||||
MainExceptionFilter.logger.error(
|
||||
traceString + ' Unkown exception: ' + exception,
|
||||
);
|
||||
exception = Fail(FT.Internal, 'Unknown exception', exception);
|
||||
exception = this.transformKnownExceptions(exception);
|
||||
}
|
||||
|
||||
const status = exception.getCode();
|
||||
@@ -65,4 +62,20 @@ export class MainExceptionFilter implements ExceptionFilter {
|
||||
|
||||
response.status(status).send(toSend);
|
||||
}
|
||||
|
||||
private transformKnownExceptions(exception: any): Failure {
|
||||
if (exception instanceof UnauthorizedException) {
|
||||
return Fail(FT.Permission, exception);
|
||||
} else if (exception instanceof ForbiddenException) {
|
||||
return Fail(FT.Permission, exception);
|
||||
} else if (exception instanceof NotFoundException) {
|
||||
return Fail(FT.NotFound, exception);
|
||||
} else if (exception instanceof MethodNotAllowedException) {
|
||||
return Fail(FT.NotFound, exception);
|
||||
} else if (exception instanceof Error) {
|
||||
return Fail(FT.Internal, exception);
|
||||
} else {
|
||||
return Fail(FT.Unknown, exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</ngx-dropzone>
|
||||
|
||||
<div class="centered" *ngIf="!canUpload">
|
||||
<h1>Please Log In</h1>
|
||||
<h1><a routerLink="/user/login">Please Log In</a></h1>
|
||||
<p>You do not yet have permission to upload</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,3 +20,20 @@ ngx-dropzone {
|
||||
.centered {
|
||||
padding-inline: 1rem;
|
||||
}
|
||||
|
||||
// unstyle a href
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
|
||||
&:hover {
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
&:active {
|
||||
color: inherit;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user