mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(server): auth/oauth (#3242)
* refactor(server): auth/oauth * fix: show server error message on login failure
This commit is contained in:
parent
9ef41bf1c7
commit
08c7054845
30 changed files with 453 additions and 730 deletions
|
|
@ -2,13 +2,7 @@ import type { ApiError } from '@api';
|
|||
import { CanceledError } from 'axios';
|
||||
import { notificationController, NotificationType } from '../components/shared-components/notification/notification';
|
||||
|
||||
export async function handleError(error: unknown, message: string) {
|
||||
if (error instanceof CanceledError) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(`[handleError]: ${message}`, error);
|
||||
|
||||
export async function getServerErrorMessage(error: unknown) {
|
||||
let data = (error as ApiError)?.response?.data;
|
||||
if (data instanceof Blob) {
|
||||
const response = await data.text();
|
||||
|
|
@ -19,7 +13,17 @@ export async function handleError(error: unknown, message: string) {
|
|||
}
|
||||
}
|
||||
|
||||
let serverMessage = data?.message;
|
||||
return data?.message || null;
|
||||
}
|
||||
|
||||
export async function handleError(error: unknown, message: string) {
|
||||
if (error instanceof CanceledError) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(`[handleError]: ${message}`, error);
|
||||
|
||||
let serverMessage = await getServerErrorMessage(error);
|
||||
if (serverMessage) {
|
||||
serverMessage = `${String(serverMessage).slice(0, 75)}\n(Immich Server Error)`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue