Files
outline/server/models/IntegrationAuthentication.ts
Tom Moor ac07724f21 chore: Synchronizing refactor and small fixes from enterprise codebase (#3634)
* chore: Syncronizing refactor and small fixes from enterprise codebase

* fix
2022-06-05 00:59:41 -07:00

54 lines
1.0 KiB
TypeScript

import {
DataType,
Table,
ForeignKey,
BelongsTo,
Column,
} from "sequelize-typescript";
import Team from "./Team";
import User from "./User";
import IdModel from "./base/IdModel";
import Encrypted, {
getEncryptedColumn,
setEncryptedColumn,
} from "./decorators/Encrypted";
import Fix from "./decorators/Fix";
@Table({ tableName: "authentications", modelName: "authentication" })
@Fix
class IntegrationAuthentication extends IdModel {
@Column
service: string;
@Column(DataType.ARRAY(DataType.STRING))
scopes: string[];
@Column(DataType.BLOB)
@Encrypted
get token() {
return getEncryptedColumn(this, "token");
}
set token(value: string) {
setEncryptedColumn(this, "token", value);
}
// associations
@BelongsTo(() => User, "userId")
user: User;
@ForeignKey(() => User)
@Column(DataType.UUID)
userId: string;
@BelongsTo(() => Team, "teamId")
team: Team;
@ForeignKey(() => Team)
@Column(DataType.UUID)
teamId: string;
}
export default IntegrationAuthentication;