onLoad() {
this.role=uniCloud.getCurrentUserInfo().role;
console.log("onLoad:role",this.role,uniCloud.getCurrentUserInfo());
}
实际数据库:
"role": [
"counsellor",
"L5"
],
产品分类: uniCloud/App
onLoad() {
this.role=uniCloud.getCurrentUserInfo().role;
console.log("onLoad:role",this.role,uniCloud.getCurrentUserInfo());
}
实际数据库:
"role": [
"counsellor",
"L5"
],
每次启动小程序进入页面时,调用onLoad,获得调试信息:onLoad:role ["counsellor", ob: Observer] {uid: "65f98a10a7c432936b30e275", role: Array(1), permission: Array(0), uniIdVersion: "1.0.16", tokenExpired: 1716106344000}
应该是: ["counsellor","L5", ob: Observer],少了"L5"
每次启动小程序进入页面时,调用onLoad,获得调试信息:onLoad:role ["counsellor", ob: Observer] {uid: "65f98a10a7c432936b30e275", role: Array(1), permission: Array(0), uniIdVersion: "1.0.16", tokenExpired: 1716106344000}
使用在微信小程序端调用uniCloud.getCurrentUserInfo().role获取当前用户的role信息,每次只返回role数组只有一个值,是用户的第一个角色,请问这是什么情况?
2 个回复
systhinker (作者)
奇怪,换个另外的用户仍旧通过onloda调用这个函数,居然还给出错误结果:
数据库:
{
......
}
调用结果:
onLoad:role (2) ["student", "L1", ob: Observer] {uid: "65f7f1ef21821b6d2beb9f66", role: Array(2), permission: Array(0), uniIdVersion: "1.0.16", tokenExpired: 1715953277000}
明明是L4,返回L1,这啥问题?
DCloud_uniCloud_WYQ
注意getCurrentUserInfo获取的是token内缓存的角色信息,你如果修改了用户的角色权限,需要他重新登录或者自动刷新了token才会取到新的