Browse Source

fix: clear all user related cache on user delete

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
1c8e6b97e6
  1. 2
      packages/nc-gui/components/account/UserList.vue
  2. 1
      packages/nocodb/src/lib/meta/api/orgUserApis.ts
  3. 9
      packages/nocodb/src/lib/models/User.ts

2
packages/nc-gui/components/account/UserList.vue

@ -249,7 +249,7 @@ const copyPasswordResetUrl = async (user: User) => {
</div>
</a-menu-item>
</template>
<a-menu-item v-else>
<a-menu-item>
<div class="flex flex-row items-center py-3" @click="copyPasswordResetUrl(record)">
<MdiContentCopy class="flex h-[1rem] text-gray-500" />
<div class="text-xs pl-2">{{ $t('activity.copyPasswordResetURL') }}</div>

1
packages/nocodb/src/lib/meta/api/orgUserApis.ts

@ -72,7 +72,6 @@ async function userDelete(req, res) {
// delete user
await User.delete(req.params.userId, ncMeta);
await User.delete(req.params.userId, ncMeta);
await ncMeta.commit();
} catch (e) {
await ncMeta.rollback(e);

9
packages/nocodb/src/lib/models/User.ts

@ -225,8 +225,17 @@ export default class User implements UserType {
static async delete(userId: string, ncMeta = Noco.ncMeta) {
if (!userId) NcError.badRequest('userId is required');
const user = await this.get(userId, ncMeta);
if (!user) NcError.badRequest('User not found');
// clear all user related cache
await NocoCache.delAll(CacheScope.USER, `${userId}___*`);
await NocoCache.delAll(CacheScope.USER, `${user.email}___*`);
await NocoCache.del(`${CacheScope.USER}:${userId}`);
await NocoCache.del(`${CacheScope.USER}:${user.email}`);
await ncMeta.metaDelete(null, null, MetaTable.USERS, userId);
}
}

Loading…
Cancel
Save