@tomei/sso 0.15.5 → 0.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/unit/components/login-user/login-user.spec.ts +16 -16
- package/dist/__tests__/unit/components/login-user/login-user.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/login-user/login-user.spec.js +663 -0
- package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -0
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.d.ts +1 -0
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js +38 -0
- package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js.map +1 -0
- package/dist/__tests__/unit/redis-client/redis.service.spec.d.ts +1 -0
- package/dist/__tests__/unit/redis-client/redis.service.spec.js +32 -0
- package/dist/__tests__/unit/redis-client/redis.service.spec.js.map +1 -0
- package/dist/__tests__/unit/session/session.service.spec.d.ts +1 -0
- package/dist/__tests__/unit/session/session.service.spec.js +55 -0
- package/dist/__tests__/unit/session/session.service.spec.js.map +1 -0
- package/dist/__tests__/unit/system-privilege/system-privilage.spec.d.ts +0 -0
- package/dist/__tests__/unit/system-privilege/system-privilage.spec.js +6 -0
- package/dist/__tests__/unit/system-privilege/system-privilage.spec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/src/components/building/building.d.ts +39 -0
- package/dist/src/components/building/building.js +129 -0
- package/dist/src/components/building/building.js.map +1 -0
- package/dist/src/components/building/building.repository.d.ts +6 -0
- package/dist/src/components/building/building.repository.js +38 -0
- package/dist/src/components/building/building.repository.js.map +1 -0
- package/dist/src/components/building/index.d.ts +2 -0
- package/dist/src/components/building/index.js +19 -0
- package/dist/src/components/building/index.js.map +1 -0
- package/dist/src/components/building-type/building-type.repository.d.ts +5 -0
- package/dist/src/components/building-type/building-type.repository.js +12 -0
- package/dist/src/components/building-type/building-type.repository.js.map +1 -0
- package/dist/src/components/building-type/index.d.ts +1 -0
- package/dist/src/components/building-type/index.js +18 -0
- package/dist/src/components/building-type/index.js.map +1 -0
- package/dist/src/components/index.d.ts +10 -0
- package/dist/src/components/index.js +27 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/login-history/index.d.ts +1 -0
- package/dist/src/components/login-history/index.js +18 -0
- package/dist/src/components/login-history/index.js.map +1 -0
- package/dist/src/components/login-history/login-history.repository.d.ts +5 -0
- package/dist/src/components/login-history/login-history.repository.js +12 -0
- package/dist/src/components/login-history/login-history.repository.js.map +1 -0
- package/dist/src/components/login-user/index.d.ts +3 -0
- package/dist/src/components/login-user/index.js +20 -0
- package/dist/src/components/login-user/index.js.map +1 -0
- package/dist/src/components/login-user/interfaces/index.d.ts +1 -0
- package/dist/src/components/login-user/interfaces/index.js +18 -0
- package/dist/src/components/login-user/interfaces/index.js.map +1 -0
- package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +27 -0
- package/dist/src/components/login-user/interfaces/user-info.interface.js +3 -0
- package/dist/src/components/login-user/interfaces/user-info.interface.js.map +1 -0
- package/dist/src/components/login-user/login-user.d.ts +92 -0
- package/dist/src/components/login-user/login-user.js +588 -0
- package/dist/src/components/login-user/login-user.js.map +1 -0
- package/dist/src/components/login-user/user.repository.d.ts +5 -0
- package/dist/src/components/login-user/user.repository.js +12 -0
- package/dist/src/components/login-user/user.repository.js.map +1 -0
- package/dist/src/components/password-hash/index.d.ts +2 -0
- package/dist/src/components/password-hash/index.js +19 -0
- package/dist/src/components/password-hash/index.js.map +1 -0
- package/dist/src/components/password-hash/interfaces/index.d.ts +1 -0
- package/dist/src/components/password-hash/interfaces/index.js +18 -0
- package/dist/src/components/password-hash/interfaces/index.js.map +1 -0
- package/dist/src/components/password-hash/interfaces/password-hash-service.interface.d.ts +4 -0
- package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js +3 -0
- package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js.map +1 -0
- package/dist/src/components/password-hash/password-hash.service.d.ts +6 -0
- package/dist/src/components/password-hash/password-hash.service.js +28 -0
- package/dist/src/components/password-hash/password-hash.service.js.map +1 -0
- package/dist/src/components/staff/index.d.ts +2 -0
- package/dist/src/components/staff/index.js +19 -0
- package/dist/src/components/staff/index.js.map +1 -0
- package/dist/src/components/staff/staff.d.ts +50 -0
- package/dist/src/components/staff/staff.js +102 -0
- package/dist/src/components/staff/staff.js.map +1 -0
- package/dist/src/components/staff/staff.repository.d.ts +6 -0
- package/dist/src/components/staff/staff.repository.js +38 -0
- package/dist/src/components/staff/staff.repository.js.map +1 -0
- package/dist/src/components/system/index.d.ts +1 -0
- package/dist/src/components/system/index.js +18 -0
- package/dist/src/components/system/index.js.map +1 -0
- package/dist/src/components/system/system.repository.d.ts +5 -0
- package/dist/src/components/system/system.repository.js +12 -0
- package/dist/src/components/system/system.repository.js.map +1 -0
- package/dist/src/components/system-access/index.d.ts +1 -0
- package/dist/src/components/system-access/index.js +18 -0
- package/dist/src/components/system-access/index.js.map +1 -0
- package/dist/src/components/system-access/system-access.repository.d.ts +5 -0
- package/dist/src/components/system-access/system-access.repository.js +12 -0
- package/dist/src/components/system-access/system-access.repository.js.map +1 -0
- package/dist/src/components/system-privilege/privilege.d.ts +6 -0
- package/dist/src/components/system-privilege/privilege.js +77 -0
- package/dist/src/components/system-privilege/privilege.js.map +1 -0
- package/dist/src/components/system-privilege/system-privilege.repository.d.ts +6 -0
- package/dist/src/components/system-privilege/system-privilege.repository.js +35 -0
- package/dist/src/components/system-privilege/system-privilege.repository.js.map +1 -0
- package/dist/src/components/user-group/index.d.ts +1 -0
- package/dist/src/components/user-group/index.js +18 -0
- package/dist/src/components/user-group/index.js.map +1 -0
- package/dist/src/components/user-group/user-group.repository.d.ts +5 -0
- package/dist/src/components/user-group/user-group.repository.js +12 -0
- package/dist/src/components/user-group/user-group.repository.js.map +1 -0
- package/dist/src/components/user-user-group/index.d.ts +1 -0
- package/dist/src/components/user-user-group/index.js +18 -0
- package/dist/src/components/user-user-group/index.js.map +1 -0
- package/dist/src/components/user-user-group/user-user-group.repository.d.ts +5 -0
- package/dist/src/components/user-user-group/user-user-group.repository.js +12 -0
- package/dist/src/components/user-user-group/user-user-group.repository.js.map +1 -0
- package/dist/src/database.d.ts +4 -0
- package/dist/src/database.js +15 -0
- package/dist/src/database.js.map +1 -0
- package/dist/src/enum/index.js +18 -0
- package/dist/src/enum/index.js.map +1 -0
- package/dist/src/enum/yn.enum.d.ts +4 -0
- package/dist/src/enum/yn.enum.js +9 -0
- package/dist/src/enum/yn.enum.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +24 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +2 -0
- package/dist/src/interfaces/index.js +19 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/system-login.interface.d.ts +6 -0
- package/dist/src/interfaces/system-login.interface.js +3 -0
- package/dist/src/interfaces/system-login.interface.js.map +1 -0
- package/dist/src/interfaces/user-session.interface.d.ts +4 -0
- package/dist/src/interfaces/user-session.interface.js +3 -0
- package/dist/src/interfaces/user-session.interface.js.map +1 -0
- package/dist/src/models/authorization-code.entity.d.ts +14 -0
- package/dist/src/models/authorization-code.entity.js +86 -0
- package/dist/src/models/authorization-code.entity.js.map +1 -0
- package/dist/src/models/bearer-token.entity.d.ts +11 -0
- package/dist/src/models/bearer-token.entity.js +72 -0
- package/dist/src/models/bearer-token.entity.js.map +1 -0
- package/dist/src/models/building-type.entity.d.ts +7 -0
- package/dist/src/models/building-type.entity.js +50 -0
- package/dist/src/models/building-type.entity.js.map +1 -0
- package/dist/src/models/building.entity.d.ts +39 -0
- package/dist/src/models/building.entity.js +251 -0
- package/dist/src/models/building.entity.js.map +1 -0
- package/dist/src/models/city.entity.d.ts +11 -0
- package/dist/src/models/city.entity.js +72 -0
- package/dist/src/models/city.entity.js.map +1 -0
- package/dist/src/models/company.entity.d.ts +18 -0
- package/dist/src/models/company.entity.js +114 -0
- package/dist/src/models/company.entity.js.map +1 -0
- package/dist/src/models/country.entity.d.ts +13 -0
- package/dist/src/models/country.entity.js +76 -0
- package/dist/src/models/country.entity.js.map +1 -0
- package/dist/src/models/department.entity.d.ts +19 -0
- package/dist/src/models/department.entity.js +112 -0
- package/dist/src/models/department.entity.js.map +1 -0
- package/dist/src/models/group-role-privilege.entity.d.ts +17 -0
- package/dist/src/models/group-role-privilege.entity.js +90 -0
- package/dist/src/models/group-role-privilege.entity.js.map +1 -0
- package/dist/src/models/group-system-access.entity.d.ts +11 -0
- package/dist/src/models/group-system-access.entity.js +62 -0
- package/dist/src/models/group-system-access.entity.js.map +1 -0
- package/dist/src/models/group-system-privilege.entity.d.ts +11 -0
- package/dist/src/models/group-system-privilege.entity.js +62 -0
- package/dist/src/models/group-system-privilege.entity.js.map +1 -0
- package/dist/src/models/group-system-role.entity.d.ts +11 -0
- package/dist/src/models/group-system-role.entity.js +62 -0
- package/dist/src/models/group-system-role.entity.js.map +1 -0
- package/dist/src/models/login-history.entity.d.ts +12 -0
- package/dist/src/models/login-history.entity.js +70 -0
- package/dist/src/models/login-history.entity.js.map +1 -0
- package/dist/src/models/oauth-token.entity.d.ts +14 -0
- package/dist/src/models/oauth-token.entity.js +86 -0
- package/dist/src/models/oauth-token.entity.js.map +1 -0
- package/dist/src/models/role.entity.d.ts +17 -0
- package/dist/src/models/role.entity.js +102 -0
- package/dist/src/models/role.entity.js.map +1 -0
- package/dist/src/models/staff-type.entity.d.ts +7 -0
- package/dist/src/models/staff-type.entity.js +50 -0
- package/dist/src/models/staff-type.entity.js.map +1 -0
- package/dist/src/models/staff.entity.d.ts +39 -0
- package/dist/src/models/staff.entity.js +250 -0
- package/dist/src/models/staff.entity.js.map +1 -0
- package/dist/src/models/state.entity.d.ts +10 -0
- package/dist/src/models/state.entity.js +64 -0
- package/dist/src/models/state.entity.js.map +1 -0
- package/dist/src/models/system-accesss.entity.d.ts +6 -0
- package/dist/src/models/system-accesss.entity.js +51 -0
- package/dist/src/models/system-accesss.entity.js.map +1 -0
- package/dist/src/models/system-privilege.entity.d.ts +16 -0
- package/dist/src/models/system-privilege.entity.js +90 -0
- package/dist/src/models/system-privilege.entity.js.map +1 -0
- package/dist/src/models/system-role-privilege.entity.d.ts +11 -0
- package/dist/src/models/system-role-privilege.entity.js +60 -0
- package/dist/src/models/system-role-privilege.entity.js.map +1 -0
- package/dist/src/models/system-role.entity.d.ts +11 -0
- package/dist/src/models/system-role.entity.js +83 -0
- package/dist/src/models/system-role.entity.js.map +1 -0
- package/dist/src/models/system.entity.d.ts +19 -0
- package/dist/src/models/system.entity.js +146 -0
- package/dist/src/models/system.entity.js.map +1 -0
- package/dist/src/models/user-group.entity.d.ts +23 -0
- package/dist/src/models/user-group.entity.js +140 -0
- package/dist/src/models/user-group.entity.js.map +1 -0
- package/dist/src/models/user-role.entity.d.ts +12 -0
- package/dist/src/models/user-role.entity.js +73 -0
- package/dist/src/models/user-role.entity.js.map +1 -0
- package/dist/src/models/user-system-privileges.entity.d.ts +13 -0
- package/dist/src/models/user-system-privileges.entity.js +89 -0
- package/dist/src/models/user-system-privileges.entity.js.map +1 -0
- package/dist/src/models/user-system-role.entity.d.ts +11 -0
- package/dist/src/models/user-system-role.entity.js +60 -0
- package/dist/src/models/user-system-role.entity.js.map +1 -0
- package/dist/src/models/user-user-group.entity.d.ts +14 -0
- package/dist/src/models/user-user-group.entity.js +73 -0
- package/dist/src/models/user-user-group.entity.js.map +1 -0
- package/dist/src/models/user.entity.d.ts +40 -0
- package/dist/src/models/user.entity.js +191 -0
- package/dist/src/models/user.entity.js.map +1 -0
- package/dist/src/redis-client/__mocks__/jest-initial-setup.d.ts +1 -0
- package/dist/src/redis-client/__mocks__/jest-initial-setup.js +5 -0
- package/dist/src/redis-client/__mocks__/jest-initial-setup.js.map +1 -0
- package/dist/src/redis-client/__mocks__/redis-mock.d.ts +2 -0
- package/dist/src/redis-client/__mocks__/redis-mock.js +23 -0
- package/dist/src/redis-client/__mocks__/redis-mock.js.map +1 -0
- package/dist/src/redis-client/index.d.ts +1 -0
- package/dist/src/redis-client/index.js +18 -0
- package/dist/src/redis-client/index.js.map +1 -0
- package/dist/src/redis-client/redis.service.d.ts +7 -0
- package/dist/src/redis-client/redis.service.js +61 -0
- package/dist/src/redis-client/redis.service.js.map +1 -0
- package/dist/src/session/index.d.ts +2 -0
- package/dist/src/session/index.js +19 -0
- package/dist/src/session/index.js.map +1 -0
- package/dist/src/session/interfaces/index.d.ts +1 -0
- package/dist/src/session/interfaces/index.js +18 -0
- package/dist/src/session/interfaces/index.js.map +1 -0
- package/dist/src/session/interfaces/session-service.interface.d.ts +6 -0
- package/dist/src/session/interfaces/session-service.interface.js +3 -0
- package/dist/src/session/interfaces/session-service.interface.js.map +1 -0
- package/dist/src/session/session.service.d.ts +10 -0
- package/dist/src/session/session.service.js +63 -0
- package/dist/src/session/session.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/migrations/{20240314080604-create-user-user-group-table.js → 04-create-user-user-group-table.js} +1 -1
- package/migrations/{20240314080605-create-login-history-table.js → 05-create-login-history-table.js} +1 -1
- package/package.json +2 -3
- package/src/components/login-user/interfaces/user-info.interface.ts +1 -21
- package/src/components/login-user/login-user.ts +34 -226
- package/src/models/user.entity.ts +19 -69
- package/migrations/20240314080603-create-user-table.js +0 -108
- package/src/enum/yn.enum.ts +0 -4
- /package/{src/enum/index.ts → dist/src/enum/index.d.ts} +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
import { LoginUserBase } from '@tomei/general';
|
1
|
+
import { IAddress, LoginUserBase } from '@tomei/general';
|
2
2
|
import { ISessionService } from '../../session/interfaces/session-service.interface';
|
3
|
-
import {
|
3
|
+
import { IUserInfo } from './interfaces/user-info.interface';
|
4
4
|
import { UserRepository } from './user.repository';
|
5
5
|
import { SystemRepository } from '../system/system.repository';
|
6
6
|
import { SystemAccessRepository } from '../system-access/system-access.repository';
|
@@ -16,29 +16,18 @@ import LoginHistory from '../../models/login-history.entity';
|
|
16
16
|
import GroupSystemPrivilege from '../../models/group-system-privilege.entity';
|
17
17
|
import GroupRolePrivilege from '../../models/group-role-privilege.entity';
|
18
18
|
import UserGroup from '../../models/user-group.entity';
|
19
|
-
import { YN } from '../../enum/yn.enum';
|
20
19
|
|
21
20
|
export class LoginUser extends LoginUserBase {
|
22
|
-
|
21
|
+
FullName: string;
|
22
|
+
IDNo: string;
|
23
|
+
IDType: string;
|
23
24
|
Email: string;
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
private _LastLoginAt: Date;
|
29
|
-
private _MFAEnabled: number;
|
30
|
-
private _MFAConfig: string;
|
31
|
-
private _RecoveryEmail: string;
|
32
|
-
private _FailedLoginAttemptCount: number;
|
33
|
-
private _LastFailedLoginAt: Date;
|
34
|
-
private _LastPasswordChangedAt: Date;
|
35
|
-
private _NeedToChangePasswordYN: YN;
|
36
|
-
private _CreatedById: number;
|
37
|
-
private _CreatedAt: Date;
|
38
|
-
private _UpdatedById: number;
|
39
|
-
private _UpdatedAt: Date;
|
25
|
+
ContactNo: string;
|
26
|
+
Password: string;
|
27
|
+
DefaultAddress: IAddress;
|
28
|
+
ObjectId: string;
|
40
29
|
ObjectName = 'User';
|
41
|
-
TableName = '
|
30
|
+
TableName = 'sso_users';
|
42
31
|
ObjectType = 'User';
|
43
32
|
staffs: any;
|
44
33
|
|
@@ -53,142 +42,6 @@ export class LoginUser extends LoginUserBase {
|
|
53
42
|
private static _UserGroupRepository = new UserGroupRepository();
|
54
43
|
private _dbTransaction: any;
|
55
44
|
|
56
|
-
get UserId(): number {
|
57
|
-
return parseInt(this.ObjectId);
|
58
|
-
}
|
59
|
-
|
60
|
-
private set UserId(value: number) {
|
61
|
-
this.ObjectId = value.toString();
|
62
|
-
}
|
63
|
-
|
64
|
-
get Password(): string {
|
65
|
-
return this._Password;
|
66
|
-
}
|
67
|
-
|
68
|
-
private set Password(value: string) {
|
69
|
-
this._Password = value;
|
70
|
-
}
|
71
|
-
|
72
|
-
get Status(): string {
|
73
|
-
return this._Status;
|
74
|
-
}
|
75
|
-
|
76
|
-
private set Status(value: string) {
|
77
|
-
this._Status = value;
|
78
|
-
}
|
79
|
-
|
80
|
-
get DefaultPasswordChangedYN(): YN {
|
81
|
-
return this._DefaultPasswordChangedYN;
|
82
|
-
}
|
83
|
-
|
84
|
-
private set DefaultPasswordChangedYN(value: YN) {
|
85
|
-
this._DefaultPasswordChangedYN = value;
|
86
|
-
}
|
87
|
-
|
88
|
-
get FirstLoginAt(): Date {
|
89
|
-
return this._FirstLoginAt;
|
90
|
-
}
|
91
|
-
|
92
|
-
private set FirstLoginAt(value: Date) {
|
93
|
-
this._FirstLoginAt = value;
|
94
|
-
}
|
95
|
-
|
96
|
-
get LastLoginAt(): Date {
|
97
|
-
return this._LastLoginAt;
|
98
|
-
}
|
99
|
-
|
100
|
-
private set LastLoginAt(value: Date) {
|
101
|
-
this._LastLoginAt = value;
|
102
|
-
}
|
103
|
-
|
104
|
-
get MFAEnabled(): number {
|
105
|
-
return this._MFAEnabled;
|
106
|
-
}
|
107
|
-
|
108
|
-
private set MFAEnabled(value: number) {
|
109
|
-
this._MFAEnabled = value;
|
110
|
-
}
|
111
|
-
|
112
|
-
get MFAConfig(): string {
|
113
|
-
return this._MFAConfig;
|
114
|
-
}
|
115
|
-
|
116
|
-
private set MFAConfig(value: string) {
|
117
|
-
this._MFAConfig = value;
|
118
|
-
}
|
119
|
-
|
120
|
-
get RecoveryEmail(): string {
|
121
|
-
return this._RecoveryEmail;
|
122
|
-
}
|
123
|
-
|
124
|
-
private set RecoveryEmail(value: string) {
|
125
|
-
this._RecoveryEmail = value;
|
126
|
-
}
|
127
|
-
|
128
|
-
get FailedLoginAttemptCount(): number {
|
129
|
-
return this._FailedLoginAttemptCount;
|
130
|
-
}
|
131
|
-
|
132
|
-
private set FailedLoginAttemptCount(value: number) {
|
133
|
-
this._FailedLoginAttemptCount = value;
|
134
|
-
}
|
135
|
-
|
136
|
-
get LastFailedLoginAt(): Date {
|
137
|
-
return this._LastFailedLoginAt;
|
138
|
-
}
|
139
|
-
|
140
|
-
private set LastFailedLoginAt(value: Date) {
|
141
|
-
this._LastFailedLoginAt = value;
|
142
|
-
}
|
143
|
-
|
144
|
-
get LastPasswordChangedAt(): Date {
|
145
|
-
return this._LastPasswordChangedAt;
|
146
|
-
}
|
147
|
-
|
148
|
-
private set LastPasswordChangedAt(value: Date) {
|
149
|
-
this._LastPasswordChangedAt = value;
|
150
|
-
}
|
151
|
-
|
152
|
-
get NeedToChangePasswordYN(): YN {
|
153
|
-
return this._NeedToChangePasswordYN;
|
154
|
-
}
|
155
|
-
|
156
|
-
private set NeedToChangePasswordYN(value: YN) {
|
157
|
-
this._NeedToChangePasswordYN = value;
|
158
|
-
}
|
159
|
-
|
160
|
-
get CreatedById(): number {
|
161
|
-
return this._CreatedById;
|
162
|
-
}
|
163
|
-
|
164
|
-
private set CreatedById(value: number) {
|
165
|
-
this._CreatedById = value;
|
166
|
-
}
|
167
|
-
|
168
|
-
get CreatedAt(): Date {
|
169
|
-
return this._CreatedAt;
|
170
|
-
}
|
171
|
-
|
172
|
-
private set CreatedAt(value: Date) {
|
173
|
-
this._CreatedAt = value;
|
174
|
-
}
|
175
|
-
|
176
|
-
get UpdatedById(): number {
|
177
|
-
return this._UpdatedById;
|
178
|
-
}
|
179
|
-
|
180
|
-
private set UpdatedById(value: number) {
|
181
|
-
this._UpdatedById = value;
|
182
|
-
}
|
183
|
-
|
184
|
-
get UpdatedAt(): Date {
|
185
|
-
return this._UpdatedAt;
|
186
|
-
}
|
187
|
-
|
188
|
-
private set UpdatedAt(value: Date) {
|
189
|
-
this._UpdatedAt = value;
|
190
|
-
}
|
191
|
-
|
192
45
|
async getDetails(): Promise<{
|
193
46
|
FullName: string;
|
194
47
|
IDNo: string;
|
@@ -208,7 +61,7 @@ export class LoginUser extends LoginUserBase {
|
|
208
61
|
private constructor(
|
209
62
|
sessionService: ISessionService,
|
210
63
|
dbTransaction?: any,
|
211
|
-
userInfo?:
|
64
|
+
userInfo?: IUserInfo,
|
212
65
|
) {
|
213
66
|
super();
|
214
67
|
this._SessionService = sessionService;
|
@@ -218,7 +71,7 @@ export class LoginUser extends LoginUserBase {
|
|
218
71
|
}
|
219
72
|
// set all the class properties
|
220
73
|
if (userInfo) {
|
221
|
-
this.
|
74
|
+
this.ObjectId = userInfo.ObjectId;
|
222
75
|
this.FullName = userInfo.FullName;
|
223
76
|
this.IDNo = userInfo.IDNo;
|
224
77
|
this.Email = userInfo.Email;
|
@@ -230,7 +83,7 @@ export class LoginUser extends LoginUserBase {
|
|
230
83
|
|
231
84
|
static async init(
|
232
85
|
sessionService: ISessionService,
|
233
|
-
userId?:
|
86
|
+
userId?: string,
|
234
87
|
dbTransaction = null,
|
235
88
|
): Promise<LoginUser> {
|
236
89
|
if (userId) {
|
@@ -239,7 +92,7 @@ export class LoginUser extends LoginUserBase {
|
|
239
92
|
}
|
240
93
|
const user = await LoginUser._Repository.findOne({
|
241
94
|
where: {
|
242
|
-
|
95
|
+
id: Number(userId),
|
243
96
|
},
|
244
97
|
include: [
|
245
98
|
{
|
@@ -253,32 +106,17 @@ export class LoginUser extends LoginUserBase {
|
|
253
106
|
}
|
254
107
|
|
255
108
|
if (user) {
|
256
|
-
const
|
257
|
-
|
109
|
+
const userInfo: IUserInfo = {
|
110
|
+
ObjectId: user.id.toString(),
|
258
111
|
FullName: user.Staff.FullName,
|
259
112
|
IDNo: user.Staff.IdNo,
|
260
113
|
ContactNo: user.Staff.Mobile,
|
261
114
|
Email: user.Email,
|
262
115
|
Password: user.Password,
|
263
|
-
Status: user.Status,
|
264
|
-
DefaultPasswordChangedYN: user.DefaultPasswordChangedYN,
|
265
|
-
FirstLoginAt: user.FirstLoginAt,
|
266
|
-
LastLoginAt: user.LastLoginAt,
|
267
|
-
MFAEnabled: user.MFAEnabled,
|
268
|
-
MFAConfig: user.MFAConfig,
|
269
|
-
RecoveryEmail: user.RecoveryEmail,
|
270
|
-
FailedLoginAttemptCount: user.FailedLoginAttemptCount,
|
271
|
-
LastFailedLoginAt: user.LastFailedLoginAt,
|
272
|
-
LastPasswordChangedAt: user.LastPasswordChangedAt,
|
273
|
-
NeedToChangePasswordYN: user.NeedToChangePasswordYN,
|
274
|
-
CreatedById: user.CreatedById,
|
275
|
-
CreatedAt: user.CreatedAt,
|
276
|
-
UpdatedById: user.UpdatedById,
|
277
|
-
UpdatedAt: user.UpdatedAt,
|
278
116
|
staffs: user.Staff,
|
279
117
|
};
|
280
118
|
|
281
|
-
return new LoginUser(sessionService, dbTransaction,
|
119
|
+
return new LoginUser(sessionService, dbTransaction, userInfo);
|
282
120
|
} else {
|
283
121
|
throw new Error('User not found');
|
284
122
|
}
|
@@ -306,53 +144,23 @@ export class LoginUser extends LoginUserBase {
|
|
306
144
|
],
|
307
145
|
});
|
308
146
|
|
309
|
-
const
|
310
|
-
|
147
|
+
const userInfo: IUserInfo = {
|
148
|
+
ObjectId: user.id.toString(),
|
311
149
|
FullName: user.Staff.FullName,
|
312
150
|
IDNo: user.Staff.IdNo,
|
313
151
|
ContactNo: user.Staff.Mobile,
|
314
|
-
Email: user.Email,
|
152
|
+
Email: user.Staff.Email,
|
315
153
|
Password: user.Password,
|
316
|
-
Status: user.Status,
|
317
|
-
DefaultPasswordChangedYN: user.DefaultPasswordChangedYN,
|
318
|
-
FirstLoginAt: user.FirstLoginAt,
|
319
|
-
LastLoginAt: user.LastLoginAt,
|
320
|
-
MFAEnabled: user.MFAEnabled,
|
321
|
-
MFAConfig: user.MFAConfig,
|
322
|
-
RecoveryEmail: user.RecoveryEmail,
|
323
|
-
FailedLoginAttemptCount: user.FailedLoginAttemptCount,
|
324
|
-
LastFailedLoginAt: user.LastFailedLoginAt,
|
325
|
-
LastPasswordChangedAt: user.LastPasswordChangedAt,
|
326
|
-
NeedToChangePasswordYN: user.NeedToChangePasswordYN,
|
327
|
-
CreatedById: user.CreatedById,
|
328
|
-
CreatedAt: user.CreatedAt,
|
329
|
-
UpdatedById: user.UpdatedById,
|
330
|
-
UpdatedAt: user.UpdatedAt,
|
331
154
|
staffs: user.Staff,
|
332
155
|
};
|
333
156
|
|
334
|
-
this.
|
335
|
-
this.FullName =
|
336
|
-
this.IDNo =
|
337
|
-
this.Email =
|
338
|
-
this.ContactNo =
|
339
|
-
this.Password =
|
340
|
-
this.
|
341
|
-
this.DefaultPasswordChangedYN = userAttr.DefaultPasswordChangedYN;
|
342
|
-
this.FirstLoginAt = userAttr.FirstLoginAt;
|
343
|
-
this.LastLoginAt = userAttr.LastLoginAt;
|
344
|
-
this.MFAEnabled = userAttr.MFAEnabled;
|
345
|
-
this.MFAConfig = userAttr.MFAConfig;
|
346
|
-
this.RecoveryEmail = userAttr.RecoveryEmail;
|
347
|
-
this.FailedLoginAttemptCount = userAttr.FailedLoginAttemptCount;
|
348
|
-
this.LastFailedLoginAt = userAttr.LastFailedLoginAt;
|
349
|
-
this.LastPasswordChangedAt = userAttr.LastPasswordChangedAt;
|
350
|
-
this.NeedToChangePasswordYN = userAttr.NeedToChangePasswordYN;
|
351
|
-
this.CreatedById = userAttr.CreatedById;
|
352
|
-
this.CreatedAt = userAttr.CreatedAt;
|
353
|
-
this.UpdatedById = userAttr.UpdatedById;
|
354
|
-
this.UpdatedAt = userAttr.UpdatedAt;
|
355
|
-
this.staffs = userAttr.staffs;
|
157
|
+
this.ObjectId = userInfo.ObjectId;
|
158
|
+
this.FullName = userInfo.FullName;
|
159
|
+
this.IDNo = userInfo.IDNo;
|
160
|
+
this.Email = userInfo.Email;
|
161
|
+
this.ContactNo = userInfo.ContactNo;
|
162
|
+
this.Password = userInfo.Password;
|
163
|
+
this.staffs = userInfo.staffs;
|
356
164
|
}
|
357
165
|
|
358
166
|
if (this.ObjectId && this.Email !== email) {
|
@@ -381,9 +189,9 @@ export class LoginUser extends LoginUserBase {
|
|
381
189
|
}
|
382
190
|
|
383
191
|
//validate system access
|
384
|
-
await this.checkSystemAccess(this.
|
192
|
+
await this.checkSystemAccess(this.ObjectId, system.id);
|
385
193
|
// alert user if new login
|
386
|
-
await this.alertNewLogin(this.ObjectId, system.id.toString(), ipAddress);
|
194
|
+
// await this.alertNewLogin(this.ObjectId, system.id.toString(), ipAddress);
|
387
195
|
|
388
196
|
// fetch user session if exists
|
389
197
|
const userSession = await this._SessionService.retrieveUserSession(
|
@@ -417,20 +225,20 @@ export class LoginUser extends LoginUserBase {
|
|
417
225
|
|
418
226
|
// record new login history
|
419
227
|
await LoginUser._LoginHistoryRepository.create({
|
420
|
-
UserId: this.
|
228
|
+
UserId: this.ObjectId,
|
421
229
|
SystemId: system.id,
|
422
230
|
OriginIp: ipAddress,
|
423
231
|
CreatedAt: new Date(),
|
424
232
|
});
|
425
233
|
|
426
|
-
return `${this.
|
234
|
+
return `${this.ObjectId}:${sessionId}`;
|
427
235
|
} catch (error) {
|
428
236
|
throw error;
|
429
237
|
}
|
430
238
|
}
|
431
239
|
|
432
240
|
private async checkSystemAccess(
|
433
|
-
userId:
|
241
|
+
userId: string,
|
434
242
|
systemId: number,
|
435
243
|
): Promise<void> {
|
436
244
|
try {
|
@@ -615,7 +423,7 @@ export class LoginUser extends LoginUserBase {
|
|
615
423
|
try {
|
616
424
|
return await LoginUser._UserUserGroupRepository.findAll({
|
617
425
|
where: {
|
618
|
-
UserId: this.
|
426
|
+
UserId: this.ObjectId,
|
619
427
|
SystemId: systemCode,
|
620
428
|
},
|
621
429
|
include: {
|
@@ -645,7 +453,7 @@ export class LoginUser extends LoginUserBase {
|
|
645
453
|
try {
|
646
454
|
const userRole = await LoginUser._Repository.findOne({
|
647
455
|
where: {
|
648
|
-
|
456
|
+
id: this.ObjectId,
|
649
457
|
},
|
650
458
|
include: {
|
651
459
|
model: SystemPrivilege,
|
@@ -23,108 +23,61 @@ import SystemRole from './system-role.entity';
|
|
23
23
|
import UserSystemRole from './user-system-role.entity';
|
24
24
|
import SystemPrivilege from './system-privilege.entity';
|
25
25
|
import UserSystemPrivileges from './user-system-privileges.entity';
|
26
|
-
import { YN } from '../enum/yn.enum';
|
27
26
|
|
28
27
|
@Table({
|
29
|
-
tableName: '
|
28
|
+
tableName: 'sso_users',
|
30
29
|
timestamps: true,
|
31
|
-
createdAt: '
|
32
|
-
updatedAt: '
|
30
|
+
createdAt: 'created_at',
|
31
|
+
updatedAt: 'updated_at',
|
33
32
|
})
|
34
33
|
export default class User extends Model {
|
35
34
|
@Column({
|
36
35
|
primaryKey: true,
|
37
|
-
allowNull: false,
|
38
36
|
type: DataType.INTEGER,
|
39
37
|
})
|
40
|
-
|
38
|
+
id: number;
|
41
39
|
|
42
40
|
@Column({
|
43
|
-
allowNull: false,
|
44
41
|
type: DataType.STRING,
|
42
|
+
field: 'email',
|
45
43
|
})
|
46
44
|
Email: string;
|
47
45
|
|
48
46
|
@Column({
|
49
|
-
allowNull: false,
|
50
47
|
type: DataType.STRING,
|
48
|
+
field: 'password',
|
51
49
|
})
|
52
50
|
Password: string;
|
53
51
|
|
54
52
|
@Column({
|
55
|
-
allowNull: false,
|
56
53
|
type: DataType.STRING,
|
54
|
+
field: 'status',
|
57
55
|
})
|
58
56
|
Status: string;
|
59
57
|
|
60
58
|
@Column({
|
61
|
-
|
62
|
-
|
59
|
+
type: DataType.BOOLEAN,
|
60
|
+
field: 'default_password_changed',
|
63
61
|
})
|
64
|
-
|
62
|
+
DefaultPasswordChanged: boolean;
|
65
63
|
|
66
64
|
@Column({
|
67
65
|
type: DataType.DATE,
|
66
|
+
field: 'first_login_at',
|
68
67
|
})
|
69
|
-
FirstLoginAt:
|
68
|
+
FirstLoginAt: boolean;
|
70
69
|
|
70
|
+
@ForeignKey(() => UserGroup)
|
71
71
|
@Column({
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
@Column({
|
77
|
-
type: DataType.TINYINT,
|
78
|
-
})
|
79
|
-
MFAEnabled: number;
|
80
|
-
|
81
|
-
@Column({
|
82
|
-
type: DataType.TEXT,
|
83
|
-
})
|
84
|
-
MFAConfig: string;
|
85
|
-
|
86
|
-
@Column({
|
87
|
-
type: DataType.STRING,
|
72
|
+
allowNull: true,
|
73
|
+
type: DataType.STRING(10),
|
74
|
+
field: 'GroupCode',
|
88
75
|
})
|
89
|
-
|
90
|
-
|
91
|
-
@Column({
|
92
|
-
allowNull: false,
|
93
|
-
type: DataType.INTEGER,
|
94
|
-
})
|
95
|
-
FailedLoginAttemptCount: number;
|
96
|
-
|
97
|
-
@Column({
|
98
|
-
type: DataType.DATE,
|
99
|
-
})
|
100
|
-
LastFailedLoginAt: Date;
|
101
|
-
|
102
|
-
@Column({
|
103
|
-
type: DataType.DATE,
|
104
|
-
})
|
105
|
-
LastPasswordChangedAt: Date;
|
106
|
-
|
107
|
-
@Column({
|
108
|
-
allowNull: false,
|
109
|
-
type: DataType.CHAR(1),
|
110
|
-
})
|
111
|
-
NeedToChangePasswordYN: YN;
|
112
|
-
|
113
|
-
@ForeignKey(() => User)
|
114
|
-
@Column({
|
115
|
-
type: DataType.INTEGER,
|
116
|
-
})
|
117
|
-
CreatedById: number;
|
76
|
+
GroupCode: boolean;
|
118
77
|
|
119
78
|
@CreatedAt
|
120
79
|
CreatedAt: Date;
|
121
80
|
|
122
|
-
@ForeignKey(() => User)
|
123
|
-
@Column({
|
124
|
-
type: DataType.INTEGER,
|
125
|
-
})
|
126
|
-
UpdatedById: number;
|
127
|
-
|
128
81
|
@UpdatedAt
|
129
82
|
UpdatedAt: Date;
|
130
83
|
|
@@ -152,9 +105,6 @@ export default class User extends Model {
|
|
152
105
|
@BelongsToMany(() => SystemPrivilege, () => UserSystemPrivileges)
|
153
106
|
SystemPrivileges: SystemPrivilege[];
|
154
107
|
|
155
|
-
@BelongsTo(() =>
|
156
|
-
|
157
|
-
|
158
|
-
@BelongsTo(() => User, 'UpdatedById')
|
159
|
-
UpdatedBy: User;
|
108
|
+
@BelongsTo(() => UserGroup)
|
109
|
+
UserGroup: UserGroup;
|
160
110
|
}
|
@@ -1,108 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
/** @type {import('sequelize-cli').Migration} */
|
4
|
-
module.exports = {
|
5
|
-
async up(queryInterface, Sequelize) {
|
6
|
-
await queryInterface.createTable('sso_User', {
|
7
|
-
UserId: {
|
8
|
-
primaryKey: true,
|
9
|
-
type: Sequelize.INTEGER,
|
10
|
-
allowNull: false,
|
11
|
-
autoIncrement: true,
|
12
|
-
},
|
13
|
-
Email: {
|
14
|
-
type: Sequelize.STRING,
|
15
|
-
allowNull: false,
|
16
|
-
unique: true,
|
17
|
-
},
|
18
|
-
Password: {
|
19
|
-
type: Sequelize.STRING,
|
20
|
-
allowNull: false,
|
21
|
-
},
|
22
|
-
Status: {
|
23
|
-
type: Sequelize.STRING,
|
24
|
-
allowNull: false,
|
25
|
-
},
|
26
|
-
DefaultPasswordChangedYN: {
|
27
|
-
type: Sequelize.CHAR(1),
|
28
|
-
allowNull: true,
|
29
|
-
},
|
30
|
-
FirstLoginAt: {
|
31
|
-
type: Sequelize.DATE,
|
32
|
-
allowNull: true,
|
33
|
-
},
|
34
|
-
LastLoginAt: {
|
35
|
-
type: Sequelize.DATE,
|
36
|
-
allowNull: true,
|
37
|
-
},
|
38
|
-
MFAEnabled: {
|
39
|
-
type: Sequelize.TINYINT,
|
40
|
-
allowNull: true,
|
41
|
-
},
|
42
|
-
MFAConfig: {
|
43
|
-
type: Sequelize.TEXT,
|
44
|
-
allowNull: true,
|
45
|
-
},
|
46
|
-
RecoveryEmail: {
|
47
|
-
type: Sequelize.STRING,
|
48
|
-
allowNull: true,
|
49
|
-
},
|
50
|
-
FailedLoginAttemptCount: {
|
51
|
-
type: Sequelize.INTEGER,
|
52
|
-
allowNull: false,
|
53
|
-
},
|
54
|
-
LastFailedLoginAt: {
|
55
|
-
type: Sequelize.DATE,
|
56
|
-
allowNull: true,
|
57
|
-
},
|
58
|
-
LastPasswordChangedAt: {
|
59
|
-
type: Sequelize.DATE,
|
60
|
-
allowNull: true,
|
61
|
-
},
|
62
|
-
NeedToChangePasswordYN: {
|
63
|
-
type: Sequelize.CHAR(1),
|
64
|
-
allowNull: true,
|
65
|
-
},
|
66
|
-
CreatedAt: {
|
67
|
-
allowNull: false,
|
68
|
-
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
|
69
|
-
type: Sequelize.DATE,
|
70
|
-
},
|
71
|
-
CreatedById: {
|
72
|
-
type: Sequelize.INTEGER,
|
73
|
-
allowNull: true,
|
74
|
-
references: {
|
75
|
-
model: 'sso_User',
|
76
|
-
key: 'UserId',
|
77
|
-
},
|
78
|
-
onDelete: 'CASCADE',
|
79
|
-
onUpdate: 'CASCADE',
|
80
|
-
},
|
81
|
-
UpdatedAt: {
|
82
|
-
allowNull: false,
|
83
|
-
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)'),
|
84
|
-
type: Sequelize.DATE,
|
85
|
-
},
|
86
|
-
UpdatedById: {
|
87
|
-
type: Sequelize.INTEGER,
|
88
|
-
allowNull: true,
|
89
|
-
references: {
|
90
|
-
model: 'sso_User',
|
91
|
-
key: 'UserId',
|
92
|
-
},
|
93
|
-
onDelete: 'CASCADE',
|
94
|
-
onUpdate: 'CASCADE',
|
95
|
-
},
|
96
|
-
|
97
|
-
});
|
98
|
-
},
|
99
|
-
|
100
|
-
async down(queryInterface, Sequelize) {
|
101
|
-
/**
|
102
|
-
* Add reverting commands here.
|
103
|
-
*
|
104
|
-
* Example:
|
105
|
-
* await queryInterface.dropTable('users');
|
106
|
-
*/
|
107
|
-
}
|
108
|
-
};
|
package/src/enum/yn.enum.ts
DELETED
File without changes
|