@tomei/sso 0.15.6 → 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/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 +1 -2
- package/src/components/login-user/interfaces/user-info.interface.ts +9 -29
- package/src/components/login-user/login-user.ts +557 -749
- package/src/models/user.entity.ts +110 -160
- package/migrations/20240314080603-create-user-table.js +0 -108
- package/src/enum/index.ts +0 -1
- package/src/enum/yn.enum.ts +0 -4
@@ -430,7 +430,7 @@ describe('login-user', () => {
|
|
430
430
|
.spyOn(SystemRepository.prototype, 'findOne')
|
431
431
|
.mockResolvedValue(system as any);
|
432
432
|
|
433
|
-
jest.spyOn(SMTPMailer.prototype, 'send').mockImplementation(async () => {
|
433
|
+
jest.spyOn(SMTPMailer.prototype, 'send').mockImplementation(async () => {});
|
434
434
|
|
435
435
|
const getUserGroupFromDBMock = jest.spyOn(
|
436
436
|
LoginUser.prototype as any,
|
@@ -503,7 +503,7 @@ describe('login-user', () => {
|
|
503
503
|
|
504
504
|
it('should able to do login process when no session is already available', async () => {
|
505
505
|
const sessionService = await SessionService.init();
|
506
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
506
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
507
507
|
const result = await loginUser.login(
|
508
508
|
'EZC',
|
509
509
|
'ezcash+florence@tomei.com.my',
|
@@ -515,7 +515,7 @@ describe('login-user', () => {
|
|
515
515
|
|
516
516
|
it('should able to do login process when session is already available', async () => {
|
517
517
|
const sessionService = await SessionService.init();
|
518
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
518
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
519
519
|
const result = await loginUser.login(
|
520
520
|
'EZC',
|
521
521
|
'ezcash+florence@tomei.com.my',
|
@@ -533,7 +533,7 @@ describe('login-user', () => {
|
|
533
533
|
|
534
534
|
it('should be able to login when user only have one user group with level 1 or higher', async () => {
|
535
535
|
const sessionService = await SessionService.init();
|
536
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
536
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
537
537
|
const result = await loginUser['getPrivileges']('EZC');
|
538
538
|
expect(getUserGroupFromDBMock).toBeCalledTimes(2);
|
539
539
|
expect(result).toEqual([
|
@@ -556,7 +556,7 @@ describe('login-user', () => {
|
|
556
556
|
userUserGroups.push(userUserGroups[0]);
|
557
557
|
|
558
558
|
const sessionService = await SessionService.init();
|
559
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
559
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
560
560
|
const result = await loginUser['getPrivileges']('EZC');
|
561
561
|
expect(getUserUserGroupFromDBMock).toBeCalledTimes(1);
|
562
562
|
expect(getUserGroupFromDBMock).toBeCalledTimes(4);
|
@@ -582,7 +582,7 @@ describe('login-user', () => {
|
|
582
582
|
userUserGroups = [];
|
583
583
|
|
584
584
|
const sessionService = await SessionService.init();
|
585
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
585
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
586
586
|
const result = await loginUser['getPrivileges']('EZC');
|
587
587
|
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
588
588
|
expect(result).toEqual(['Terminate Data']);
|
@@ -597,7 +597,7 @@ describe('login-user', () => {
|
|
597
597
|
user.SystemPrivileges = [];
|
598
598
|
|
599
599
|
const sessionService = await SessionService.init();
|
600
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
600
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
601
601
|
const result = await loginUser['getPrivileges']('EZC');
|
602
602
|
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
603
603
|
expect(result).toEqual([
|
@@ -619,7 +619,7 @@ describe('login-user', () => {
|
|
619
619
|
user.SystemPrivileges = [];
|
620
620
|
|
621
621
|
const sessionService = await SessionService.init();
|
622
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
622
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
623
623
|
const result = await loginUser['getPrivileges']('EZC');
|
624
624
|
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
625
625
|
expect(result).toEqual([
|
@@ -640,7 +640,7 @@ describe('login-user', () => {
|
|
640
640
|
userUserGroups = [];
|
641
641
|
|
642
642
|
const sessionService = await SessionService.init();
|
643
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
643
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
644
644
|
const result = await loginUser['getPrivileges']('EZC');
|
645
645
|
expect(getUserGroupFromDBMock).toBeCalledTimes(0);
|
646
646
|
expect(result).toEqual([]);
|
@@ -658,7 +658,7 @@ describe('login-user', () => {
|
|
658
658
|
it('should return false if user session not found', async () => {
|
659
659
|
isSessionExist = false;
|
660
660
|
const sessionService = await SessionService.init();
|
661
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
661
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
662
662
|
const result = await loginUser.checkPrivileges('EZC', 'Terminate');
|
663
663
|
expect(result).toEqual(false);
|
664
664
|
});
|
@@ -666,7 +666,7 @@ describe('login-user', () => {
|
|
666
666
|
it('should return false if system login not found', async () => {
|
667
667
|
isSessionExist = false;
|
668
668
|
const sessionService = await SessionService.init();
|
669
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
669
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
670
670
|
const result = await loginUser.checkPrivileges('EZC', 'Terminate');
|
671
671
|
expect(result).toEqual(false);
|
672
672
|
});
|
@@ -674,14 +674,14 @@ describe('login-user', () => {
|
|
674
674
|
it('should return false if privilege not found', async () => {
|
675
675
|
isSessionExist = false;
|
676
676
|
const sessionService = await SessionService.init();
|
677
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
677
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
678
678
|
const result = await loginUser.checkPrivileges('EZC', 'Not Terminate');
|
679
679
|
expect(result).toEqual(false);
|
680
680
|
});
|
681
681
|
|
682
682
|
it('should return true if privilege found', async () => {
|
683
683
|
const sessionService = await SessionService.init();
|
684
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
684
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
685
685
|
const result = await loginUser.checkPrivileges('EZC', 'Terminate');
|
686
686
|
expect(result).toEqual(true);
|
687
687
|
});
|
@@ -696,7 +696,7 @@ describe('login-user', () => {
|
|
696
696
|
try {
|
697
697
|
isSessionExist = false;
|
698
698
|
const sessionService = await SessionService.init();
|
699
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
699
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
700
700
|
await loginUser.checkSession(
|
701
701
|
'EZC',
|
702
702
|
session.systemLogins[0].sessionId,
|
@@ -710,7 +710,7 @@ describe('login-user', () => {
|
|
710
710
|
it('it should returns session expired if sessionId not matched', async () => {
|
711
711
|
try {
|
712
712
|
const sessionService = await SessionService.init();
|
713
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
713
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
714
714
|
await loginUser.checkSession(
|
715
715
|
'NOTEZC',
|
716
716
|
session.systemLogins[0].sessionId,
|
@@ -730,7 +730,7 @@ describe('login-user', () => {
|
|
730
730
|
}
|
731
731
|
});
|
732
732
|
const sessionService = await SessionService.init();
|
733
|
-
const loginUser = await LoginUser.init(sessionService, 755);
|
733
|
+
const loginUser = await LoginUser.init(sessionService, '755');
|
734
734
|
const result = await loginUser.checkSession(
|
735
735
|
'EZC',
|
736
736
|
session.systemLogins[0].sessionId,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tomei/sso",
|
3
|
-
"version": "0.15.
|
3
|
+
"version": "0.15.7",
|
4
4
|
"description": "Tomei SSO Package",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
@@ -46,7 +46,6 @@
|
|
46
46
|
"prettier": "^2.7.1",
|
47
47
|
"prisma": "^4.14.0",
|
48
48
|
"redis-mock": "^0.56.3",
|
49
|
-
"sequelize-cli": "^6.6.2",
|
50
49
|
"ts-jest": "^29.1.0",
|
51
50
|
"ts-node": "^10.9.1",
|
52
51
|
"tsc-watch": "^5.0.3",
|
@@ -1,29 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
staffs?: any;
|
11
|
-
}
|
12
|
-
|
13
|
-
export interface IUserAttr extends IUserInfo {
|
14
|
-
Status: string;
|
15
|
-
DefaultPasswordChangedYN: YN;
|
16
|
-
FirstLoginAt: Date;
|
17
|
-
LastLoginAt: Date;
|
18
|
-
MFAEnabled: number;
|
19
|
-
MFAConfig: string;
|
20
|
-
RecoveryEmail: string;
|
21
|
-
FailedLoginAttemptCount: number;
|
22
|
-
LastFailedLoginAt: Date;
|
23
|
-
LastPasswordChangedAt: Date;
|
24
|
-
NeedToChangePasswordYN: YN;
|
25
|
-
CreatedById: number;
|
26
|
-
CreatedAt: Date;
|
27
|
-
UpdatedById: number;
|
28
|
-
UpdatedAt: Date;
|
29
|
-
}
|
1
|
+
export interface IUserInfo {
|
2
|
+
FullName: string;
|
3
|
+
IDNo: string;
|
4
|
+
Email: string;
|
5
|
+
ContactNo: string;
|
6
|
+
ObjectId: string;
|
7
|
+
Password: string;
|
8
|
+
staffs?: any;
|
9
|
+
}
|