allow unprotected pages

This commit is contained in:
Sebastian Sdorra
2018-07-13 10:57:11 +02:00
parent 8ff84abf67
commit 5c59c6bac6
19 changed files with 567 additions and 450 deletions

View File

@@ -3,8 +3,8 @@
// get api base url from environment
const apiUrl = process.env.API_URL || process.env.PUBLIC_URL || "/scm";
export const PAGE_NOT_FOUND_ERROR = Error("page not found");
export const NOT_AUTHENTICATED_ERROR = Error("not authenticated");
export const NOT_FOUND_ERROR = Error("not found");
export const UNAUTHORIZED_ERROR = Error("unauthorized");
const fetchOptions: RequestOptions = {
credentials: "same-origin",
@@ -16,10 +16,10 @@ const fetchOptions: RequestOptions = {
function handleStatusCode(response: Response) {
if (!response.ok) {
if (response.status === 401) {
throw NOT_AUTHENTICATED_ERROR;
throw UNAUTHORIZED_ERROR;
}
if (response.status === 404) {
throw PAGE_NOT_FOUND_ERROR;
throw NOT_FOUND_ERROR;
}
throw new Error("server returned status code " + response.status);
}