Merge pull request #292 from answerdev/feat/1.0.8/ui

fix: guard add 403 code error response
This commit is contained in:
dashuai 2023-03-28 14:25:11 +08:00 committed by GitHub
commit 2ee1ace4d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -182,6 +182,10 @@ export const admin = () => {
const us = deriveLoginState();
if (gr.ok && !us.isAdmin) {
gr.ok = false;
gr.error = {
code: '403',
msg: '',
};
gr.redirect = '';
}
return gr;
@ -192,7 +196,11 @@ export const isAdminOrModerator = () => {
const us = deriveLoginState();
if (gr.ok && !us.isAdmin && !us.isModerator) {
gr.ok = false;
gr.redirect = RouteAlias.home;
gr.error = {
code: '403',
msg: '',
};
gr.redirect = '';
}
return gr;
};