在服务器端,我有以下代码用于登录:
return jsonify({'email': email, 'token': create_token(email, isAdmin, password)})
在客户端,我需要代码来检查登录并检查是否为管理员。
isLogged() {
if (localStorage.getItem('currentUser') &&
JSON.parse(localStorage.getItem('currentUser')).email) {
return true;
}
return false;
}
isAdmin(){
//???
}
我怎样从令牌中获取用户角色?