-
Notifications
You must be signed in to change notification settings - Fork 70
/
auth-user.model.ts
103 lines (89 loc) · 1.76 KB
/
auth-user.model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {model, property} from '@loopback/repository';
import {
IAuthUserWithPermissions,
IUserPrefs,
UserStatus,
} from '@sourceloop/core';
import {User} from '../../../models';
export class DeviceInfo {
userAgent?: string;
deviceId?: string;
}
@model({
description: `This is the signature for authenticated user which holds permissions and role.`,
settings: {strict: true},
})
export class AuthUser
extends User<AuthUser>
implements IAuthUserWithPermissions
{
@property({
type: 'array',
itemType: 'string',
})
permissions: string[];
@property({
type: 'string',
required: true,
})
role: string;
@property({
type: 'string',
})
externalAuthToken?: string;
@property({
type: 'object',
description: `This property consists of two optional fields.
1. userAgent
2. deviceId `,
})
deviceInfo?: DeviceInfo;
@property({
type: 'number',
})
age?: number;
@property({
type: 'string',
})
externalRefreshToken?: string;
@property({
type: 'number',
})
authClientId: number;
@property({
type: 'object',
})
userPreferences?: IUserPrefs;
@property({
type: 'string',
})
tenantId?: string;
@property({
type: 'string',
})
userTenantId?: string;
@property({
type: 'date',
})
passwordExpiryTime?: Date;
@property({
type: 'number',
jsonSchema: {
enum: [
UserStatus.ACTIVE,
UserStatus.INACTIVE,
UserStatus.PASSWORD_CHANGE_NEEDED,
UserStatus.REGISTERED,
UserStatus.REJECTED,
],
},
})
status?: UserStatus;
getIdentifier() {
return this.id;
}
}