feat: Phase 3 FBA UI 预构建产物 + Phase 4 按钮级权限(fba_jwt + perms)(Epic #159)
This commit is contained in:
+24
-1
@@ -446,6 +446,27 @@ var IAOP_SESSION = (function () {
|
||||
.catch(function () { return modulesFor(user.role); });
|
||||
}
|
||||
|
||||
/* ---- Epic #159 Phase 4:按钮级权限码 ------------------------------------
|
||||
* FBA GET /auth/codes 返回当前用户权限码集合(服务端按角色聚合;
|
||||
* 超管返回全部菜单 perms,含播种脚本写入的 iaop:<module>)。
|
||||
* 结果按会话缓存(登录后只拉一次),非 FBA 轨道返回空数组。 */
|
||||
var _codesCache = null; // Promise<string[]> | null
|
||||
function perms() {
|
||||
if (_codesCache) return _codesCache;
|
||||
if (!readFbaToken()) return Promise.resolve([]);
|
||||
_codesCache = fbaFetch("/auth/codes")
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
return d && d.code === 200 && Array.isArray(d.data) ? d.data : [];
|
||||
})
|
||||
.catch(function () { return []; });
|
||||
return _codesCache;
|
||||
}
|
||||
function hasPerm(code) {
|
||||
return perms().then(function (codes) {
|
||||
return codes.indexOf(code) >= 0;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
MODULES: MODULES,
|
||||
@@ -461,7 +482,9 @@ var IAOP_SESSION = (function () {
|
||||
fbaStatus: fbaStatus,
|
||||
getCaptcha: getCaptcha,
|
||||
getAuthHeaders: getAuthHeaders,
|
||||
menuTree: menuTree
|
||||
menuTree: menuTree,
|
||||
perms: perms,
|
||||
hasPerm: hasPerm
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user