Skip to content

Commit

Permalink
feat: add column type to User Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaltation committed Oct 30, 2024
1 parent 914a2fe commit 37a459b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/common/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -19,6 +27,7 @@ export interface UserInfo {
* via a share. Otherwise null.
*/
ShareRef: number | null;
Type: UserTypes | null;
[attributes: string]: unknown;
}

Expand All @@ -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<string, unknown> = {}) {
Expand Down
4 changes: 4 additions & 0 deletions app/gen-server/entity/User.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 37a459b

Please sign in to comment.