@tomei/sso 0.66.1-test.3 → 0.66.1-test.4

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.
Files changed (43) hide show
  1. package/__tests__/unit/components/login-user/login.spec.ts +271 -2
  2. package/__tests__/unit/components/login-user/password-expiry.spec.ts +87 -0
  3. package/dist/__tests__/unit/components/login-user/login.spec.js +199 -2
  4. package/dist/__tests__/unit/components/login-user/login.spec.js.map +1 -1
  5. package/dist/__tests__/unit/components/login-user/password-expiry.spec.d.ts +1 -0
  6. package/dist/__tests__/unit/components/login-user/password-expiry.spec.js +86 -0
  7. package/dist/__tests__/unit/components/login-user/password-expiry.spec.js.map +1 -0
  8. package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +1 -0
  9. package/dist/src/components/login-user/user.d.ts +1 -0
  10. package/dist/src/components/login-user/user.js +7 -1
  11. package/dist/src/components/login-user/user.js.map +1 -1
  12. package/dist/src/components/system/system.d.ts +1 -0
  13. package/dist/src/components/system/system.js +1 -0
  14. package/dist/src/components/system/system.js.map +1 -1
  15. package/dist/src/components/system-privilege/system-privilege.d.ts +1 -0
  16. package/dist/src/components/system-privilege/system-privilege.js +2 -0
  17. package/dist/src/components/system-privilege/system-privilege.js.map +1 -1
  18. package/dist/src/interfaces/system-privilege.interface.d.ts +1 -0
  19. package/dist/src/interfaces/system.interface.d.ts +1 -0
  20. package/dist/src/models/group.entity.d.ts +1 -0
  21. package/dist/src/models/group.entity.js +8 -1
  22. package/dist/src/models/group.entity.js.map +1 -1
  23. package/dist/src/models/system-privilege.entity.d.ts +1 -0
  24. package/dist/src/models/system-privilege.entity.js +7 -0
  25. package/dist/src/models/system-privilege.entity.js.map +1 -1
  26. package/dist/src/models/system.entity.d.ts +1 -0
  27. package/dist/src/models/system.entity.js +7 -0
  28. package/dist/src/models/system.entity.js.map +1 -1
  29. package/dist/src/models/user.entity.d.ts +1 -0
  30. package/dist/src/models/user.entity.js +7 -0
  31. package/dist/src/models/user.entity.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +1 -1
  34. package/src/components/login-user/interfaces/user-info.interface.ts +1 -0
  35. package/src/components/login-user/user.ts +14 -2
  36. package/src/components/system/system.ts +2 -0
  37. package/src/components/system-privilege/system-privilege.ts +3 -0
  38. package/src/interfaces/system-privilege.interface.ts +1 -0
  39. package/src/interfaces/system.interface.ts +1 -0
  40. package/src/models/group.entity.ts +7 -1
  41. package/src/models/system-privilege.entity.ts +6 -0
  42. package/src/models/system.entity.ts +6 -0
  43. package/src/models/user.entity.ts +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.66.1-test.3",
3
+ "version": "0.66.1-test.4",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -9,6 +9,7 @@ export interface IUserInfo {
9
9
  ContactNo: string;
10
10
  UserName: string;
11
11
  UserId?: number;
12
+ V1Id?: number;
12
13
  Password: string;
13
14
  staffs?: any;
14
15
  }
@@ -40,6 +40,7 @@ import { UserPasswordHistory } from '../user-password-history/user-password-hist
40
40
 
41
41
  export class User extends UserBase {
42
42
  ObjectId: string;
43
+ V1Id: number;
43
44
  Email: string;
44
45
  private _UserName: string;
45
46
  private _Password: string;
@@ -291,6 +292,7 @@ export class User extends UserBase {
291
292
  // set all the class properties
292
293
  if (userInfo) {
293
294
  this.UserId = userInfo.UserId;
295
+ this.V1Id = userInfo.V1Id;
294
296
  this.UserName = userInfo.UserName;
295
297
  this.FullName = userInfo.FullName;
296
298
  this.IDNo = userInfo.IDNo;
@@ -3071,6 +3073,11 @@ export class User extends UserBase {
3071
3073
  return { expired: false, expiringSoon: false, expiresInDays: null };
3072
3074
  }
3073
3075
 
3076
+ // Accounts authenticated without a local password cannot rotate one here.
3077
+ if (!this.Password) {
3078
+ return { expired: false, expiringSoon: false, expiresInDays: null };
3079
+ }
3080
+
3074
3081
  // Forces first-login change for temp-password/admin-created accounts (AC#4), regardless of password age.
3075
3082
  if (this.NeedToChangePasswordYN === YN.Yes) {
3076
3083
  return { expired: true, expiringSoon: false, expiresInDays: null };
@@ -3092,14 +3099,19 @@ export class User extends UserBase {
3092
3099
  }
3093
3100
 
3094
3101
  const createdAt = latestHistory.CreatedAt;
3102
+ const expiryMonth = createdAt.getUTCMonth() + expiryMonths;
3103
+ const lastDayOfExpiryMonth = new Date(
3104
+ Date.UTC(createdAt.getUTCFullYear(), expiryMonth + 1, 0),
3105
+ ).getUTCDate();
3095
3106
  const expiryDate = new Date(
3096
3107
  Date.UTC(
3097
3108
  createdAt.getUTCFullYear(),
3098
- createdAt.getUTCMonth() + expiryMonths,
3099
- createdAt.getUTCDate(),
3109
+ expiryMonth,
3110
+ Math.min(createdAt.getUTCDate(), lastDayOfExpiryMonth),
3100
3111
  createdAt.getUTCHours(),
3101
3112
  createdAt.getUTCMinutes(),
3102
3113
  createdAt.getUTCSeconds(),
3114
+ createdAt.getUTCMilliseconds(),
3103
3115
  ),
3104
3116
  );
3105
3117
 
@@ -10,6 +10,7 @@ import { v4 as uuidv4 } from 'uuid';
10
10
 
11
11
  export class System extends ObjectBase {
12
12
  ObjectId: string;
13
+ V1Id: number;
13
14
  ObjectName: string;
14
15
  TableName = 'sso_System';
15
16
  ObjectType = 'System';
@@ -49,6 +50,7 @@ export class System extends ObjectBase {
49
50
  private constructor(systemAttr?: ISystemAttr) {
50
51
  super();
51
52
  if (systemAttr) {
53
+ this.V1Id = systemAttr.V1Id;
52
54
  this.SystemCode = systemAttr.SystemCode;
53
55
  this.Name = systemAttr.Name;
54
56
  this.Description = systemAttr?.Description;
@@ -13,6 +13,7 @@ export class SystemPrivilege extends ObjectBase {
13
13
  ObjectType = 'SystemPrivilege';
14
14
  TableName = 'sso_SystemPrivilege';
15
15
  ObjectId: string;
16
+ V1Id: string;
16
17
  PrivilegeCode: string;
17
18
  SystemCode: string;
18
19
  ObjectName: string;
@@ -53,6 +54,7 @@ export class SystemPrivilege extends ObjectBase {
53
54
  private constructor(systemPrivilegeAttr?: ISystemPrivilegeAttr) {
54
55
  super();
55
56
  if (systemPrivilegeAttr) {
57
+ this.V1Id = systemPrivilegeAttr.V1Id;
56
58
  this.SystemPrivilegeId = systemPrivilegeAttr.SystemPrivilegeId;
57
59
  this.PrivilegeCode = systemPrivilegeAttr.PrivilegeCode;
58
60
  this.SystemCode = systemPrivilegeAttr.SystemCode;
@@ -66,6 +68,7 @@ export class SystemPrivilege extends ObjectBase {
66
68
  }
67
69
 
68
70
  setAttributes(systemPrivilegeAttr: ISystemPrivilegeAttr) {
71
+ this.V1Id = systemPrivilegeAttr.V1Id;
69
72
  this.PrivilegeCode = systemPrivilegeAttr.PrivilegeCode;
70
73
  this.SystemPrivilegeId = systemPrivilegeAttr.SystemPrivilegeId;
71
74
  this.SystemCode = systemPrivilegeAttr.SystemCode;
@@ -1,4 +1,5 @@
1
1
  export interface ISystemPrivilegeAttr {
2
+ V1Id?: string;
2
3
  SystemPrivilegeId: string;
3
4
  PrivilegeCode: string;
4
5
  SystemCode: string;
@@ -1,4 +1,5 @@
1
1
  export interface ISystemAttr {
2
+ V1Id?: number;
2
3
  SystemCode: string;
3
4
  Name: string;
4
5
  Description: string;
@@ -24,6 +24,12 @@ import GroupReportingUserModel from './group-reporting-user.entity';
24
24
  updatedAt: 'UpdatedAt',
25
25
  })
26
26
  export default class GroupModel extends Model {
27
+ @Column({
28
+ allowNull: true,
29
+ type: DataType.INTEGER,
30
+ })
31
+ V1Id: number;
32
+
27
33
  @Column({
28
34
  primaryKey: true,
29
35
  allowNull: false,
@@ -74,7 +80,7 @@ export default class GroupModel extends Model {
74
80
 
75
81
  @Column({
76
82
  allowNull: false,
77
- type: DataType.STRING(10),
83
+ type: DataType.STRING(100),
78
84
  })
79
85
  Path: string;
80
86
 
@@ -76,6 +76,12 @@ export default class SystemPrivilegeModel extends Model {
76
76
  @UpdatedAt
77
77
  UpdatedAt: Date;
78
78
 
79
+ @Column({
80
+ allowNull: true,
81
+ type: DataType.STRING(30),
82
+ })
83
+ V1Id: string;
84
+
79
85
  @BelongsTo(() => System)
80
86
  System: System;
81
87
 
@@ -96,6 +96,12 @@ export default class SystemModel extends Model {
96
96
  @UpdatedAt
97
97
  UpdatedAt: Date;
98
98
 
99
+ @Column({
100
+ allowNull: true,
101
+ type: DataType.INTEGER,
102
+ })
103
+ V1Id: number;
104
+
99
105
  @BelongsTo(() => User, 'CreatedById')
100
106
  CreatedByUser: User;
101
107
 
@@ -171,6 +171,12 @@ export default class User extends Model {
171
171
  @UpdatedAt
172
172
  UpdatedAt: Date;
173
173
 
174
+ @Column({
175
+ allowNull: true,
176
+ type: DataType.INTEGER,
177
+ })
178
+ V1Id: number;
179
+
174
180
  @HasOne(() => Staff, 'UserId')
175
181
  Staff: Staff;
176
182