Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1219 poc service accounts #1284

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add column type to User Entity
  • Loading branch information
hexaltation committed Jan 28, 2025
commit a5130a1f0c83ff29a199dc805cf12c3fcffd83e4
10 changes: 10 additions & 0 deletions app/common/User.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown> = {}) {
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,
@@ -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) {