Browse Source

refactor: review comments

pull/8027/head
Pranav C 8 months ago
parent
commit
d4d994858d
  1. 3
      packages/nocodb/src/models/User.ts
  2. 6
      packages/nocodb/src/models/UserRefreshToken.ts
  3. 1
      packages/nocodb/src/models/index.ts
  4. 10
      packages/nocodb/src/services/users/users.service.ts

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

@ -9,9 +9,8 @@ import {
CacheScope,
MetaTable,
} from '~/utils/globals';
import { Base, BaseUser } from '~/models';
import { Base, BaseUser, UserRefreshToken } from '~/models';
import { sanitiseUserObj } from '~/utils';
import UserRefreshToken from '~/models/UserRefreshToken';
export default class User implements UserType {
id: string;

6
packages/nocodb/src/models/UserRefreshToken.ts

@ -13,7 +13,7 @@ export default class UserRefreshToken {
updated_at?: any;
public static async insert(
syncLog: Partial<UserRefreshToken>,
userRefreshToken: Partial<UserRefreshToken>,
ncMeta = Noco.ncMeta,
) {
// clear old invalid tokens before inserting new one
@ -23,7 +23,7 @@ export default class UserRefreshToken {
null,
MetaTable.USER_REFRESH_TOKENS,
{
fk_user_id: syncLog.fk_user_id,
fk_user_id: userRefreshToken.fk_user_id,
},
{
expires_at: {
@ -32,7 +32,7 @@ export default class UserRefreshToken {
},
);
const insertObj = extractProps(syncLog, [
const insertObj = extractProps(userRefreshToken, [
'fk_user_id',
'token',
'expires_at',

1
packages/nocodb/src/models/index.ts

@ -40,3 +40,4 @@ export { default as View } from './View';
export { default as LinksColumn } from './LinksColumn';
export { default as Notification } from './Notification';
export { default as PresignedUrl } from './PresignedUrl';
export { default as UserRefreshToken } from './UserRefreshToken';

10
packages/nocodb/src/services/users/users.service.ts

@ -21,13 +21,12 @@ import { validatePayload } from '~/helpers';
import { MetaService } from '~/meta/meta.service';
import { MetaTable } from '~/utils/globals';
import Noco from '~/Noco';
import { Store, User } from '~/models';
import { Store, User, UserRefreshToken } from '~/models';
import { randomTokenString } from '~/helpers/stringHelpers';
import NcPluginMgrv2 from '~/helpers/NcPluginMgrv2';
import { NcError } from '~/helpers/catchError';
import { BasesService } from '~/services/bases.service';
import { extractProps } from '~/helpers/extractProps';
import UserRefreshToken from '~/models/UserRefreshToken';
@Injectable()
export class UsersService {
@ -381,11 +380,6 @@ export class UsersService {
const refreshToken = randomTokenString();
// await User.update(user.id, {
// email: user.email,
// refresh_token: refreshToken,
// });
await UserRefreshToken.insert({
token: refreshToken,
fk_user_id: user.id,
@ -584,8 +578,6 @@ export class UsersService {
}
await User.update(user.id, {
// refresh_token: refreshToken,
// email: user.email,
token_version: user['token_version'],
});

Loading…
Cancel
Save