Browse Source

fix: reset token_version in user object if null

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2393/head
Pranav C 2 years ago
parent
commit
bf4e1e49cb
  1. 7
      packages/nocodb/src/lib/meta/api/userApi/userApis.ts
  2. 3
      packages/nocodb/src/lib/models/User.ts

7
packages/nocodb/src/lib/meta/api/userApi/userApis.ts

@ -179,15 +179,14 @@ async function successfulSignIn({
await promisify((req as any).login.bind(req))(user);
const refreshToken = randomTokenString();
let token_version = user.token_version;
if (!token_version) {
token_version = randomTokenString();
if (!user.token_version) {
user.token_version = randomTokenString();
}
await User.update(user.id, {
refresh_token: refreshToken,
email: user.email,
token_version
token_version: user.token_version
});
setTokenCookie(res, refreshToken);

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

@ -84,6 +84,9 @@ export default class User implements UserType {
if (updateObj.email) {
updateObj.email = updateObj.email.toLowerCase();
} else {
// set email prop to avoid generation of invalid cache key
updateObj.email = (await this.get(id, ncMeta))?.email?.toLowerCase();
}
// get existing cache
const keys = [

Loading…
Cancel
Save