Browse Source

Merge pull request #1965 from nocodb/fix/role-upd-in-cache

fix: add missing upd cache logic when updating roles
pull/1966/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
e6a3229779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      packages/nocodb/src/lib/noco-models/ProjectUser.ts

17
packages/nocodb/src/lib/noco-models/ProjectUser.ts

@ -6,6 +6,7 @@ import {
} from '../utils/globals';
import Noco from '../noco/Noco';
import NocoCache from '../noco-cache/NocoCache';
import User from './User';
export default class ProjectUser {
project_id: string;
@ -133,6 +134,22 @@ export default class ProjectUser {
// set cache
await NocoCache.set(key, o);
}
// update user cache
const user = await User.get(userId);
if (user) {
const email = user.email;
for (const key of [
`${CacheScope.USER}:${email}`,
`${CacheScope.USER}:${email}___${projectId}`
]) {
const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT);
if (o) {
o.roles = roles;
// set cache
await NocoCache.set(key, o);
}
}
}
// set meta
return await ncMeta.metaUpdate(
null,

Loading…
Cancel
Save