feat(projects): get user info in router guard and remove in localStorage. close #459

This commit is contained in:
Soybean
2024-06-06 20:22:28 +08:00
parent 584cd54d6d
commit 5531a68641
4 changed files with 27 additions and 29 deletions

View File

@ -5,27 +5,8 @@ export function getToken() {
return localStg.get('token') || '';
}
/** Get user info */
export function getUserInfo() {
const emptyInfo: Api.Auth.UserInfo = {
userId: '',
userName: '',
roles: [],
buttons: []
};
const userInfo = localStg.get('userInfo') || emptyInfo;
// fix new property: buttons, this will be removed in the next version `1.1.0`
if (!userInfo.buttons) {
userInfo.buttons = [];
}
return userInfo;
}
/** Clear auth storage */
export function clearAuthStorage() {
localStg.remove('token');
localStg.remove('refreshToken');
localStg.remove('userInfo');
}