@tomei/sso 0.28.4 → 0.28.6

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.28.4",
3
+ "version": "0.28.6",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -369,9 +369,9 @@ export class LoginUser extends LoginUserBase {
369
369
  const userAttr: IUserAttr = {
370
370
  UserId: user.UserId,
371
371
  UserName: user.UserName,
372
- FullName: user.Staff.FullName,
373
- IDNo: user.Staff.IdNo,
374
- ContactNo: user.Staff.Mobile,
372
+ FullName: user?.Staff?.FullName || null,
373
+ IDNo: user?.Staff?.IdNo || null,
374
+ ContactNo: user?.Staff?.Mobile || null,
375
375
  Email: user.Email,
376
376
  Password: user.Password,
377
377
  Status: user.Status,
@@ -389,7 +389,7 @@ export class LoginUser extends LoginUserBase {
389
389
  CreatedAt: user.CreatedAt,
390
390
  UpdatedById: user.UpdatedById,
391
391
  UpdatedAt: user.UpdatedAt,
392
- staffs: user.Staff,
392
+ staffs: user?.Staff || null,
393
393
  };
394
394
 
395
395
  this.UserId = userAttr.UserId;
@@ -563,14 +563,18 @@ export class LoginUser extends LoginUserBase {
563
563
  this._SessionService.setUserSession(this.ObjectId, userSession);
564
564
 
565
565
  // record new login history
566
- await LoginUser._LoginHistoryRepository.create({
567
- UserId: this.UserId,
568
- SystemCode: system.SystemCode,
569
- OriginIp: ipAddress,
570
- CreatedAt: new Date(),
571
- LoginStatus: LoginStatusEnum.SUCCESS,
572
- dbTransaction,
573
- });
566
+ await LoginUser._LoginHistoryRepository.create(
567
+ {
568
+ UserId: this.UserId,
569
+ SystemCode: system.SystemCode,
570
+ OriginIp: ipAddress,
571
+ CreatedAt: new Date(),
572
+ LoginStatus: LoginStatusEnum.SUCCESS,
573
+ },
574
+ {
575
+ transaction: dbTransaction,
576
+ },
577
+ );
574
578
 
575
579
  // Retrieve is2FAEnabledYN from sso-config with ComponentConfig.
576
580
  const is2FAEnabledYN = ComponentConfig.getComponentConfigValue(
@@ -585,14 +589,18 @@ export class LoginUser extends LoginUserBase {
585
589
  return `${this.UserId}:${sessionId}`;
586
590
  } catch (error) {
587
591
  if (this.ObjectId) {
588
- await LoginUser._LoginHistoryRepository.create({
589
- UserId: this.UserId,
590
- SystemCode: systemCode,
591
- OriginIp: ipAddress,
592
- LoginStatus: LoginStatusEnum.FAILURE,
593
- CreatedAt: new Date(),
594
- dbTransaction,
595
- });
592
+ await LoginUser._LoginHistoryRepository.create(
593
+ {
594
+ UserId: this.UserId,
595
+ SystemCode: systemCode,
596
+ OriginIp: ipAddress,
597
+ LoginStatus: LoginStatusEnum.FAILURE,
598
+ CreatedAt: new Date(),
599
+ },
600
+ {
601
+ transaction: dbTransaction,
602
+ },
603
+ );
596
604
  }
597
605
  throw error;
598
606
  }