@tomei/sso 0.34.5 → 0.34.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +1 -0
- package/dist/src/components/login-user/login-user.js +4 -4
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/components/login-user/user.d.ts +1 -0
- package/dist/src/components/login-user/user.js +52 -8
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/src/models/user.entity.d.ts +5 -1
- package/dist/src/models/user.entity.js +31 -3
- package/dist/src/models/user.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/20240314080602-create-user-table.js +25 -9
- package/package.json +1 -1
- package/src/components/login-user/interfaces/user-info.interface.ts +1 -0
- package/src/components/login-user/login-user.ts +4 -3
- package/src/components/login-user/user.ts +65 -6
- package/src/models/user.entity.ts +27 -3
@@ -10,6 +10,10 @@ module.exports = {
|
|
10
10
|
allowNull: false,
|
11
11
|
autoIncrement: true,
|
12
12
|
},
|
13
|
+
UserName: {
|
14
|
+
type: Sequelize.STRING(50),
|
15
|
+
allowNull: true,
|
16
|
+
},
|
13
17
|
Email: {
|
14
18
|
type: Sequelize.STRING,
|
15
19
|
allowNull: false,
|
@@ -19,6 +23,22 @@ module.exports = {
|
|
19
23
|
type: Sequelize.STRING,
|
20
24
|
allowNull: false,
|
21
25
|
},
|
26
|
+
FullName: {
|
27
|
+
type: Sequelize.STRING(200),
|
28
|
+
allowNull: false,
|
29
|
+
},
|
30
|
+
IdNo: {
|
31
|
+
type: Sequelize.STRING(50),
|
32
|
+
allowNull: true,
|
33
|
+
},
|
34
|
+
IdType: {
|
35
|
+
type: Sequelize.STRING(20),
|
36
|
+
allowNull: true,
|
37
|
+
},
|
38
|
+
ContactNo: {
|
39
|
+
type: Sequelize.STRING(20),
|
40
|
+
allowNull: true,
|
41
|
+
},
|
22
42
|
Status: {
|
23
43
|
type: Sequelize.STRING,
|
24
44
|
allowNull: false,
|
@@ -27,10 +47,6 @@ module.exports = {
|
|
27
47
|
type: Sequelize.CHAR(1),
|
28
48
|
allowNull: true,
|
29
49
|
},
|
30
|
-
UserName: {
|
31
|
-
type: Sequelize.STRING(50),
|
32
|
-
allowNull: true,
|
33
|
-
},
|
34
50
|
FirstLoginAt: {
|
35
51
|
type: Sequelize.DATE,
|
36
52
|
allowNull: true,
|
@@ -84,7 +100,9 @@ module.exports = {
|
|
84
100
|
},
|
85
101
|
UpdatedAt: {
|
86
102
|
allowNull: false,
|
87
|
-
defaultValue: Sequelize.literal(
|
103
|
+
defaultValue: Sequelize.literal(
|
104
|
+
'CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)',
|
105
|
+
),
|
88
106
|
type: Sequelize.DATE,
|
89
107
|
},
|
90
108
|
UpdatedById: {
|
@@ -97,12 +115,10 @@ module.exports = {
|
|
97
115
|
onDelete: 'CASCADE',
|
98
116
|
onUpdate: 'CASCADE',
|
99
117
|
},
|
100
|
-
|
101
118
|
});
|
102
119
|
},
|
103
120
|
|
104
121
|
async down(queryInterface, Sequelize) {
|
105
|
-
|
106
|
-
|
107
|
-
}
|
122
|
+
await queryInterface.dropTable('sso_User');
|
123
|
+
},
|
108
124
|
};
|
package/package.json
CHANGED
@@ -43,9 +43,10 @@ export class LoginUser extends User implements ILoginUser {
|
|
43
43
|
const userAttr: IUserAttr = {
|
44
44
|
UserId: user.UserId,
|
45
45
|
UserName: user.UserName,
|
46
|
-
FullName: user?.
|
47
|
-
IDNo: user?.
|
48
|
-
|
46
|
+
FullName: user?.FullName || null,
|
47
|
+
IDNo: user?.IdNo || null,
|
48
|
+
IDType: user?.IdType || null,
|
49
|
+
ContactNo: user?.ContactNo || null,
|
49
50
|
Email: user.Email,
|
50
51
|
Password: user.Password,
|
51
52
|
Status: user.Status,
|
@@ -313,9 +313,10 @@ export class User extends UserBase {
|
|
313
313
|
const userAttr: IUserAttr = {
|
314
314
|
UserId: user.UserId,
|
315
315
|
UserName: user.UserName,
|
316
|
-
FullName: user?.
|
317
|
-
IDNo: user?.
|
318
|
-
|
316
|
+
FullName: user?.FullName || null,
|
317
|
+
IDNo: user?.IdNo || null,
|
318
|
+
IDType: user?.IdType || null,
|
319
|
+
ContactNo: user?.ContactNo || null,
|
319
320
|
Email: user.Email,
|
320
321
|
Password: user.Password,
|
321
322
|
Status: user.Status,
|
@@ -405,9 +406,10 @@ export class User extends UserBase {
|
|
405
406
|
const userAttr: IUserAttr = {
|
406
407
|
UserId: user.UserId,
|
407
408
|
UserName: user.UserName,
|
408
|
-
FullName: user?.
|
409
|
-
IDNo: user?.
|
410
|
-
|
409
|
+
FullName: user?.FullName || null,
|
410
|
+
IDNo: user?.IdNo || null,
|
411
|
+
IDType: user?.IdType || null,
|
412
|
+
ContactNo: user?.ContactNo || null,
|
411
413
|
Email: user.Email,
|
412
414
|
Password: user.Password,
|
413
415
|
Status: user.Status,
|
@@ -1316,6 +1318,7 @@ export class User extends UserBase {
|
|
1316
1318
|
UserName: user.UserName,
|
1317
1319
|
FullName: user.FullName,
|
1318
1320
|
IDNo: user.IDNo,
|
1321
|
+
IDType: user.IDType,
|
1319
1322
|
Email: user.Email,
|
1320
1323
|
ContactNo: user.ContactNo,
|
1321
1324
|
Password: user.Password,
|
@@ -2285,4 +2288,60 @@ export class User extends UserBase {
|
|
2285
2288
|
//Return Updated User Instance
|
2286
2289
|
return this;
|
2287
2290
|
}
|
2291
|
+
|
2292
|
+
public static async findById(
|
2293
|
+
loginUser: LoginUser,
|
2294
|
+
dbTransaction: any,
|
2295
|
+
UserId: string,
|
2296
|
+
) {
|
2297
|
+
const systemCode = ApplicationConfig.getComponentConfigValue('system-code');
|
2298
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
2299
|
+
systemCode,
|
2300
|
+
'USER_VIEW',
|
2301
|
+
);
|
2302
|
+
|
2303
|
+
//If user does not have privilege to update user, throw a ClassError
|
2304
|
+
if (!isPrivileged) {
|
2305
|
+
throw new ClassError(
|
2306
|
+
'LoginUser',
|
2307
|
+
'LoginUserErrMsg0X',
|
2308
|
+
'You do not have the privilege to find user',
|
2309
|
+
);
|
2310
|
+
}
|
2311
|
+
|
2312
|
+
const user = await User._Repository.findOne({
|
2313
|
+
where: {
|
2314
|
+
UserId: UserId,
|
2315
|
+
Status: 'Active',
|
2316
|
+
},
|
2317
|
+
transaction: dbTransaction,
|
2318
|
+
});
|
2319
|
+
const userAttr: IUserAttr = {
|
2320
|
+
UserId: user.UserId,
|
2321
|
+
UserName: user.UserName,
|
2322
|
+
FullName: user?.FullName || null,
|
2323
|
+
IDNo: user?.IdNo || null,
|
2324
|
+
IDType: user?.IdType || null,
|
2325
|
+
ContactNo: user?.ContactNo || null,
|
2326
|
+
Email: user.Email,
|
2327
|
+
Password: user.Password,
|
2328
|
+
Status: user.Status,
|
2329
|
+
DefaultPasswordChangedYN: user.DefaultPasswordChangedYN,
|
2330
|
+
FirstLoginAt: user.FirstLoginAt,
|
2331
|
+
LastLoginAt: user.LastLoginAt,
|
2332
|
+
MFAEnabled: user.MFAEnabled,
|
2333
|
+
MFAConfig: user.MFAConfig,
|
2334
|
+
RecoveryEmail: user.RecoveryEmail,
|
2335
|
+
FailedLoginAttemptCount: user.FailedLoginAttemptCount,
|
2336
|
+
LastFailedLoginAt: user.LastFailedLoginAt,
|
2337
|
+
LastPasswordChangedAt: user.LastPasswordChangedAt,
|
2338
|
+
NeedToChangePasswordYN: user.NeedToChangePasswordYN,
|
2339
|
+
CreatedById: user.CreatedById,
|
2340
|
+
CreatedAt: user.CreatedAt,
|
2341
|
+
UpdatedById: user.UpdatedById,
|
2342
|
+
UpdatedAt: user.UpdatedAt,
|
2343
|
+
staffs: user?.Staff || null,
|
2344
|
+
};
|
2345
|
+
return new User(null, dbTransaction, userAttr);
|
2346
|
+
}
|
2288
2347
|
}
|
@@ -34,6 +34,12 @@ export default class User extends Model {
|
|
34
34
|
})
|
35
35
|
UserId: number;
|
36
36
|
|
37
|
+
@Column({
|
38
|
+
allowNull: true,
|
39
|
+
type: DataType.STRING,
|
40
|
+
})
|
41
|
+
UserName: string;
|
42
|
+
|
37
43
|
@Column({
|
38
44
|
allowNull: false,
|
39
45
|
type: DataType.STRING,
|
@@ -41,16 +47,34 @@ export default class User extends Model {
|
|
41
47
|
Email: string;
|
42
48
|
|
43
49
|
@Column({
|
44
|
-
allowNull:
|
50
|
+
allowNull: false,
|
45
51
|
type: DataType.STRING,
|
46
52
|
})
|
47
|
-
|
53
|
+
Password: string;
|
48
54
|
|
49
55
|
@Column({
|
50
56
|
allowNull: false,
|
51
57
|
type: DataType.STRING,
|
52
58
|
})
|
53
|
-
|
59
|
+
FullName: string;
|
60
|
+
|
61
|
+
@Column({
|
62
|
+
allowNull: false,
|
63
|
+
type: DataType.STRING,
|
64
|
+
})
|
65
|
+
IdNo: string;
|
66
|
+
|
67
|
+
@Column({
|
68
|
+
allowNull: false,
|
69
|
+
type: DataType.STRING,
|
70
|
+
})
|
71
|
+
IdType: string;
|
72
|
+
|
73
|
+
@Column({
|
74
|
+
allowNull: false,
|
75
|
+
type: DataType.STRING,
|
76
|
+
})
|
77
|
+
ContactNo: string;
|
54
78
|
|
55
79
|
@Column({
|
56
80
|
allowNull: false,
|