refactor: Move API keys into their own table (no-changelog) (#10629)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Ricardo Espinoza
2024-09-26 08:58:49 -04:00
committed by GitHub
parent 7e79a46750
commit a13a4f7442
35 changed files with 630 additions and 312 deletions

View File

@@ -23,6 +23,7 @@ import { NoUrl } from '@/validators/no-url.validator';
import { NoXss } from '@/validators/no-xss.validator';
import { WithTimestamps, jsonColumnType } from './abstract-entity';
import type { ApiKey } from './api-key';
import type { AuthIdentity } from './auth-identity';
import type { ProjectRelation } from './project-relation';
import type { SharedCredentials } from './shared-credentials';
@@ -89,6 +90,9 @@ export class User extends WithTimestamps implements IUser {
@OneToMany('AuthIdentity', 'user')
authIdentities: AuthIdentity[];
@OneToMany('ApiKey', 'user')
apiKeys: ApiKey[];
@OneToMany('SharedWorkflow', 'user')
sharedWorkflows: SharedWorkflow[];
@@ -107,10 +111,6 @@ export class User extends WithTimestamps implements IUser {
this.email = this.email?.toLowerCase() ?? null;
}
@Column({ type: String, nullable: true })
@Index({ unique: true })
apiKey: string | null;
@Column({ type: Boolean, default: false })
mfaEnabled: boolean;
@@ -151,7 +151,7 @@ export class User extends WithTimestamps implements IUser {
}
toJSON() {
const { password, apiKey, ...rest } = this;
const { password, ...rest } = this;
return rest;
}