From 3a8b2657c6f51b466b8c0d6da0093d5870ed7285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Cutzach?= Date: Wed, 30 Oct 2024 10:52:20 +0100 Subject: [PATCH] feat: add column type to User Entity --- app/common/User.ts | 10 ++++++++++ app/gen-server/entity/User.ts | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/app/common/User.ts b/app/common/User.ts index 4e3419a148..36d0127c9c 100644 --- a/app/common/User.ts +++ b/app/common/User.ts @@ -2,6 +2,14 @@ import {getTableId} from 'app/common/DocActions'; import {EmptyRecordView, RecordView} from 'app/common/RecordView'; import {Role} from 'app/common/roles'; +/** + * User type to distinguish beetween Users and service accounts + */ +export enum UserTypes { + 'login', + 'service' +} + /** * Information about a user, including any user attributes. */ @@ -19,6 +27,7 @@ export interface UserInfo { * via a share. Otherwise null. */ ShareRef: number | null; + Type: UserTypes | null; [attributes: string]: unknown; } @@ -37,6 +46,7 @@ export class User implements UserInfo { public SessionID: string | null = null; public UserRef: string | null = null; public ShareRef: number | null = null; + public Type: UserTypes | null = null; [attribute: string]: any; constructor(info: Record = {}) { diff --git a/app/gen-server/entity/User.ts b/app/gen-server/entity/User.ts index b4a9909033..46fb54f5e0 100644 --- a/app/gen-server/entity/User.ts +++ b/app/gen-server/entity/User.ts @@ -1,4 +1,5 @@ import {UserOptions} from 'app/common/UserAPI'; +import {UserTypes} from 'app/common/User'; import {nativeValues} from 'app/gen-server/lib/values'; import {makeId} from 'app/server/lib/idUtils'; import {BaseEntity, BeforeInsert, Column, Entity, JoinTable, ManyToMany, OneToMany, OneToOne, @@ -64,6 +65,9 @@ export class User extends BaseEntity { @Column({name: 'ref', type: String, nullable: false}) public ref: string; + @Column({name: 'type', type: String, default: 'login'}) + public type: UserTypes | null; + @BeforeInsert() public async beforeInsert() { if (!this.ref) {