Files
n8n-enterprise-unlocked/packages/cli/src/databases/entities/AuthIdentity.ts
कारतोफ्फेलस्क्रिप्ट™ 8e392cfc1d feat(core): Migrate to n8n's typeorm fork (#8590)
2024-02-08 15:13:29 +01:00

35 lines
835 B
TypeScript

import { Column, Entity, ManyToOne, PrimaryColumn, Unique } from '@n8n/typeorm';
import { WithTimestamps } from './AbstractEntity';
import { User } from './User';
export type AuthProviderType = 'ldap' | 'email' | 'saml'; // | 'google';
@Entity()
@Unique(['providerId', 'providerType'])
export class AuthIdentity extends WithTimestamps {
@Column()
userId: string;
@ManyToOne(() => User, (user) => user.authIdentities)
user: User;
@PrimaryColumn()
providerId: string;
@PrimaryColumn()
providerType: AuthProviderType;
static create(
user: User,
providerId: string,
providerType: AuthProviderType = 'ldap',
): AuthIdentity {
const identity = new AuthIdentity();
identity.user = user;
identity.userId = user.id;
identity.providerId = providerId;
identity.providerType = providerType;
return identity;
}
}