Skip to content

Commit ca2f43a

Browse files
authored
Merge pull request #615 from devforth/feature/AdminForth/1611/display-the-appropriate-respon
Feature/admin forth/1611/display the appropriate respon
2 parents cbb36cb + 4235a91 commit ca2f43a

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

adminforth/modules/restApi.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
718718

719719

720720
if (!userRecord) {
721+
response.setStatus(401);
721722
return { error: INVALID_MESSAGE };
722723
}
723724

@@ -748,6 +749,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
748749
});
749750
}
750751
} else {
752+
response.setStatus(401);
751753
return { error: INVALID_MESSAGE };
752754
}
753755

adminforth/spa/src/utils/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export async function callApi({path, method, body, headers, silentError = false,
141141
const fullPath = `${import.meta.env.VITE_ADMINFORTH_PUBLIC_PATH || ''}${path}`;
142142
try {
143143
const r = await fetch(fullPath, options);
144-
if (r.status == 401 ) {
144+
if (r.status == 401 && !path.includes('/login')) {
145145
useUserStore().unauthorize();
146146
useCoreStore().resetAdminUser();
147147
await redirectToLogin();

adminforth/types/Back.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface IConfigValidator {
3636

3737
export interface IAdminForthHttpResponse {
3838
setHeader: (key: string, value: string) => void,
39-
setStatus: (code: number, message: string) => void,
39+
setStatus: (code: number, message?: string) => void,
4040
blobStream: () => Writable,
4141
};
4242

0 commit comments

Comments
 (0)