fix: update forbidden route handling to prevent navigation errors and return null

This commit is contained in:
Simon Larsen
2025-05-29 13:49:00 +01:00
parent 17f23b788d
commit 6a16301b3f

View File

@@ -119,10 +119,11 @@ class BaseAPI extends API {
if (
error instanceof HTTPErrorResponse &&
error.statusCode === 403 &&
this.getForbiddenRoute() &&
Navigation.getCurrentRoute().toString() !==
this.getForbiddenRoute().toString()
this.getForbiddenRoute()?.toString()
) {
Navigation.navigate(this.getForbiddenRoute(), { forceNavigate: true });
Navigation.navigate(this.getForbiddenRoute()!, { forceNavigate: true });
}
return error;
@@ -132,8 +133,8 @@ class BaseAPI extends API {
return new Route("/accounts/login");
}
protected static getForbiddenRoute(): Route {
return new Route("/accounts/forbidden");
protected static getForbiddenRoute(): Route | null {
return null;
}
public static getFriendlyMessage(