@tomei/sso 0.15.10 → 0.16.2
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/.commitlintrc.json +22 -22
- package/.eslintrc +16 -16
- package/.eslintrc.js +35 -35
- package/.husky/commit-msg +15 -15
- package/.husky/pre-commit +7 -7
- package/.prettierrc +4 -4
- package/Jenkinsfile +57 -57
- package/README.md +23 -23
- package/__tests__/unit/components/login-user/login-user.spec.ts +742 -742
- package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
- package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
- package/__tests__/unit/session/session.service.spec.ts +47 -47
- package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
- package/create-sso-user.sql +39 -39
- package/dist/__tests__/unit/components/login-user/login-user.spec.js +15 -15
- package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -1
- package/dist/src/components/building/building.d.ts +10 -3
- package/dist/src/components/building/building.js +12 -1
- package/dist/src/components/building/building.js.map +1 -1
- package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +19 -1
- package/dist/src/components/login-user/login-user.d.ts +54 -9
- package/dist/src/components/login-user/login-user.js +177 -29
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/components/staff/staff.d.ts +1 -1
- package/dist/src/components/staff/staff.js +1 -1
- package/dist/src/components/staff/staff.js.map +1 -1
- package/dist/src/enum/index.d.ts +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/models/user.entity.d.ts +16 -6
- package/dist/src/models/user.entity.js +85 -25
- package/dist/src/models/user.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.config.js +13 -13
- package/migrations/01-alter-system-privilege-table.js +13 -13
- package/migrations/02-alter-user-group-table.js +78 -78
- package/migrations/03-alter-user-system-privilege-table.js +38 -38
- package/migrations/20240314080603-create-user-table.js +108 -0
- package/migrations/{04-create-user-user-group-table.js → 20240314080604-create-user-user-group-table.js} +55 -55
- package/migrations/{05-create-login-history-table.js → 20240314080605-create-login-history-table.js} +49 -49
- package/package.json +80 -79
- package/sampledotenv +7 -7
- package/src/components/building/building.ts +18 -3
- package/src/components/login-user/interfaces/user-info.interface.ts +29 -9
- package/src/components/login-user/login-user.ts +749 -557
- package/src/components/staff/staff.ts +4 -2
- package/src/enum/index.ts +1 -0
- package/src/enum/yn.enum.ts +4 -0
- package/src/models/user.entity.ts +160 -110
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +23 -23
@@ -1,6 +1,6 @@
|
|
1
1
|
import { IAddress, IPerson, ObjectBase } from '@tomei/general';
|
2
2
|
import { StaffRepository } from './staff.repository';
|
3
|
-
import { LoginUser } from '
|
3
|
+
import { LoginUser } from '../login-user/login-user';
|
4
4
|
import { ApplicationConfig } from '@tomei/config';
|
5
5
|
import { Op } from 'sequelize';
|
6
6
|
import StaffType from '../../models/staff-type.entity';
|
@@ -64,7 +64,9 @@ export class Staff extends ObjectBase implements IPerson {
|
|
64
64
|
private constructor(staffInfo) {
|
65
65
|
super();
|
66
66
|
if (staffInfo) {
|
67
|
-
|
67
|
+
// needed to implement objectBase
|
68
|
+
this.ObjectId = staffInfo.staff_id;
|
69
|
+
|
68
70
|
this.UserId = staffInfo.user_id;
|
69
71
|
this.StaffId = staffInfo.staff_id;
|
70
72
|
this.FullName = staffInfo.full_name;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './yn.enum';
|
@@ -1,110 +1,160 @@
|
|
1
|
-
import {
|
2
|
-
BelongsTo,
|
3
|
-
BelongsToMany,
|
4
|
-
Column,
|
5
|
-
CreatedAt,
|
6
|
-
DataType,
|
7
|
-
ForeignKey,
|
8
|
-
HasMany,
|
9
|
-
HasOne,
|
10
|
-
Model,
|
11
|
-
Table,
|
12
|
-
UpdatedAt,
|
13
|
-
} from 'sequelize-typescript';
|
14
|
-
import UserGroup from './user-group.entity';
|
15
|
-
import Staff from './staff.entity';
|
16
|
-
import BearerToken from './bearer-token.entity';
|
17
|
-
import OAuthToken from './oauth-token.entity';
|
18
|
-
import UserRole from './user-role.entity';
|
19
|
-
import System from './system.entity';
|
20
|
-
import SystemAccess from './system-accesss.entity';
|
21
|
-
import Role from './role.entity';
|
22
|
-
import SystemRole from './system-role.entity';
|
23
|
-
import UserSystemRole from './user-system-role.entity';
|
24
|
-
import SystemPrivilege from './system-privilege.entity';
|
25
|
-
import UserSystemPrivileges from './user-system-privileges.entity';
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
@Column({
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
@
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
}
|
1
|
+
import {
|
2
|
+
BelongsTo,
|
3
|
+
BelongsToMany,
|
4
|
+
Column,
|
5
|
+
CreatedAt,
|
6
|
+
DataType,
|
7
|
+
ForeignKey,
|
8
|
+
HasMany,
|
9
|
+
HasOne,
|
10
|
+
Model,
|
11
|
+
Table,
|
12
|
+
UpdatedAt,
|
13
|
+
} from 'sequelize-typescript';
|
14
|
+
import UserGroup from './user-group.entity';
|
15
|
+
import Staff from './staff.entity';
|
16
|
+
import BearerToken from './bearer-token.entity';
|
17
|
+
import OAuthToken from './oauth-token.entity';
|
18
|
+
import UserRole from './user-role.entity';
|
19
|
+
import System from './system.entity';
|
20
|
+
import SystemAccess from './system-accesss.entity';
|
21
|
+
import Role from './role.entity';
|
22
|
+
import SystemRole from './system-role.entity';
|
23
|
+
import UserSystemRole from './user-system-role.entity';
|
24
|
+
import SystemPrivilege from './system-privilege.entity';
|
25
|
+
import UserSystemPrivileges from './user-system-privileges.entity';
|
26
|
+
import { YN } from '../enum/yn.enum';
|
27
|
+
|
28
|
+
@Table({
|
29
|
+
tableName: 'sso_User',
|
30
|
+
timestamps: true,
|
31
|
+
createdAt: 'CreatedAt',
|
32
|
+
updatedAt: 'UpdatedAt',
|
33
|
+
})
|
34
|
+
export default class User extends Model {
|
35
|
+
@Column({
|
36
|
+
primaryKey: true,
|
37
|
+
allowNull: false,
|
38
|
+
type: DataType.INTEGER,
|
39
|
+
})
|
40
|
+
UserId: number;
|
41
|
+
|
42
|
+
@Column({
|
43
|
+
allowNull: false,
|
44
|
+
type: DataType.STRING,
|
45
|
+
})
|
46
|
+
Email: string;
|
47
|
+
|
48
|
+
@Column({
|
49
|
+
allowNull: false,
|
50
|
+
type: DataType.STRING,
|
51
|
+
})
|
52
|
+
Password: string;
|
53
|
+
|
54
|
+
@Column({
|
55
|
+
allowNull: false,
|
56
|
+
type: DataType.STRING,
|
57
|
+
})
|
58
|
+
Status: string;
|
59
|
+
|
60
|
+
@Column({
|
61
|
+
allowNull: false,
|
62
|
+
type: DataType.CHAR(1),
|
63
|
+
})
|
64
|
+
DefaultPasswordChangedYN: YN;
|
65
|
+
|
66
|
+
@Column({
|
67
|
+
type: DataType.DATE,
|
68
|
+
})
|
69
|
+
FirstLoginAt: Date;
|
70
|
+
|
71
|
+
@Column({
|
72
|
+
type: DataType.DATE,
|
73
|
+
})
|
74
|
+
LastLoginAt: Date;
|
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,
|
88
|
+
})
|
89
|
+
RecoveryEmail: string;
|
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;
|
118
|
+
|
119
|
+
@CreatedAt
|
120
|
+
CreatedAt: Date;
|
121
|
+
|
122
|
+
@ForeignKey(() => User)
|
123
|
+
@Column({
|
124
|
+
type: DataType.INTEGER,
|
125
|
+
})
|
126
|
+
UpdatedById: number;
|
127
|
+
|
128
|
+
@UpdatedAt
|
129
|
+
UpdatedAt: Date;
|
130
|
+
|
131
|
+
@HasOne(() => Staff)
|
132
|
+
Staff: Staff;
|
133
|
+
|
134
|
+
@HasMany(() => BearerToken)
|
135
|
+
BearerTokens: BearerToken[];
|
136
|
+
|
137
|
+
@HasMany(() => OAuthToken)
|
138
|
+
OAuthTokens: OAuthToken[];
|
139
|
+
|
140
|
+
@HasMany(() => UserRole)
|
141
|
+
UserRoles: UserRole[];
|
142
|
+
|
143
|
+
@BelongsToMany(() => System, () => SystemAccess)
|
144
|
+
Systems: System[];
|
145
|
+
|
146
|
+
@BelongsToMany(() => Role, () => UserRole)
|
147
|
+
Roles: Role[];
|
148
|
+
|
149
|
+
@BelongsToMany(() => SystemRole, () => UserSystemRole)
|
150
|
+
SystemRoles: SystemRole[];
|
151
|
+
|
152
|
+
@BelongsToMany(() => SystemPrivilege, () => UserSystemPrivileges)
|
153
|
+
SystemPrivileges: SystemPrivilege[];
|
154
|
+
|
155
|
+
@BelongsTo(() => User, 'CreatedById')
|
156
|
+
CreatedBy: User;
|
157
|
+
|
158
|
+
@BelongsTo(() => User, 'UpdatedById')
|
159
|
+
UpdatedBy: User;
|
160
|
+
}
|
package/tsconfig.build.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
{
|
2
|
-
"extends": "./tsconfig.json",
|
3
|
-
"include": ["**/*.ts"],
|
4
|
-
"exclude": ["node_modules", "__tests__", "dist", "**/*spec.ts"]
|
5
|
-
}
|
1
|
+
{
|
2
|
+
"extends": "./tsconfig.json",
|
3
|
+
"include": ["**/*.ts"],
|
4
|
+
"exclude": ["node_modules", "__tests__", "dist", "**/*spec.ts"]
|
5
|
+
}
|
6
6
|
|
package/tsconfig.json
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"module": "commonjs",
|
4
|
-
"declaration": true,
|
5
|
-
"removeComments": true,
|
6
|
-
"emitDecoratorMetadata": true,
|
7
|
-
"experimentalDecorators": true,
|
8
|
-
"allowSyntheticDefaultImports": true,
|
9
|
-
"moduleResolution": "node",
|
10
|
-
"target": "es6",
|
11
|
-
"sourceMap": true,
|
12
|
-
"outDir": "./dist",
|
13
|
-
"baseUrl": "./src",
|
14
|
-
"rootDir": "./",
|
15
|
-
"incremental": true,
|
16
|
-
"skipLibCheck": true,
|
17
|
-
"noImplicitAny": false,
|
18
|
-
"strictBindCallApply": false,
|
19
|
-
"forceConsistentCasingInFileNames": false,
|
20
|
-
"noFallthroughCasesInSwitch": false,
|
21
|
-
"strictNullChecks": true,
|
22
|
-
},
|
23
|
-
}
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"module": "commonjs",
|
4
|
+
"declaration": true,
|
5
|
+
"removeComments": true,
|
6
|
+
"emitDecoratorMetadata": true,
|
7
|
+
"experimentalDecorators": true,
|
8
|
+
"allowSyntheticDefaultImports": true,
|
9
|
+
"moduleResolution": "node",
|
10
|
+
"target": "es6",
|
11
|
+
"sourceMap": true,
|
12
|
+
"outDir": "./dist",
|
13
|
+
"baseUrl": "./src",
|
14
|
+
"rootDir": "./",
|
15
|
+
"incremental": true,
|
16
|
+
"skipLibCheck": true,
|
17
|
+
"noImplicitAny": false,
|
18
|
+
"strictBindCallApply": false,
|
19
|
+
"forceConsistentCasingInFileNames": false,
|
20
|
+
"noFallthroughCasesInSwitch": false,
|
21
|
+
"strictNullChecks": true,
|
22
|
+
},
|
23
|
+
}
|