1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-06 07:21:24 +08:00

Added front-end menu permission control

This commit is contained in:
2023-05-19 18:09:41 +08:00
parent eefaa63142
commit d86de7bbcc
5 changed files with 79 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ function getLoginStatus(): boolean {
return getLocalStorage(TOKEN_NAME) != null
}
function getUsername(): string {
function getUser(): any {
const token = getToken()
if (token === null) {
@@ -30,7 +30,12 @@ function getUsername(): string {
}
const jwtPayload: JwtPayload = jwtDecode(token)
const user = JSON.parse(jwtPayload.sub ?? '')
return JSON.parse(jwtPayload.sub ?? '')
}
function getUsername(): string {
const user = getUser()
return user.staff != null
? `${_.toString(user.staff.lastName)}${_.toString(user.staff.firstName)}`
: user.username
@@ -45,4 +50,4 @@ function verifyCaptcha(value: string): boolean {
return captcha.value === value.replace(/\s*/g, '').toUpperCase()
}
export { login, logout, getLoginStatus, getUsername, getCaptchaSrc, verifyCaptcha }
export { login, logout, getLoginStatus, getUser, getUsername, getCaptchaSrc, verifyCaptcha }