@tomei/sso 0.58.10 → 0.58.12
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/dist/src/components/login-user/login-user.d.ts +1 -0
- package/dist/src/components/login-user/login-user.js +26 -0
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/enum/building-type.enum.d.ts +6 -0
- package/dist/src/enum/building-type.enum.js +11 -0
- package/dist/src/enum/building-type.enum.js.map +1 -0
- package/dist/src/models/building.entity.d.ts +9 -18
- package/dist/src/models/building.entity.js +44 -133
- package/dist/src/models/building.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/login-user/login-user.ts +43 -1
- package/src/enum/building-type.enum.ts +6 -0
- package/src/models/building.entity.ts +30 -128
package/package.json
CHANGED
@@ -8,7 +8,7 @@ import { UserRepository } from './user.repository';
|
|
8
8
|
import { IUserAttr, IUserInfo } from './interfaces/user-info.interface';
|
9
9
|
import Staff from '../../models/staff.entity';
|
10
10
|
import UserModel from '../../models/user.entity';
|
11
|
-
import { createHash, randomBytes } from 'crypto';
|
11
|
+
import { createHash, randomBytes, randomUUID } from 'crypto';
|
12
12
|
import { UserGroupRepository } from '../user-group/user-group.repository';
|
13
13
|
import GroupSystemAccessModel from '../../models/group-system-access.entity';
|
14
14
|
import SystemModel from '../../models/system.entity';
|
@@ -317,4 +317,46 @@ export class LoginUser extends User implements ILoginUser {
|
|
317
317
|
// Part 3: Map Result to System Object
|
318
318
|
return output;
|
319
319
|
}
|
320
|
+
|
321
|
+
async setSession(systemCode: string, sessionId: string, dbTransaction: any) {
|
322
|
+
// fetch user session if exists
|
323
|
+
const sessionName =
|
324
|
+
ApplicationConfig.getComponentConfigValue('sessionName');
|
325
|
+
|
326
|
+
if (!sessionName) {
|
327
|
+
throw new Error('Session name is not set in the configuration');
|
328
|
+
}
|
329
|
+
|
330
|
+
const userSession = await this._SessionService.retrieveUserSession(
|
331
|
+
this.ObjectId,
|
332
|
+
sessionName,
|
333
|
+
);
|
334
|
+
const systemLogin = userSession.systemLogins.find(
|
335
|
+
(system) => system.code === systemCode,
|
336
|
+
);
|
337
|
+
|
338
|
+
if (systemLogin) {
|
339
|
+
const privileges = await this.getPrivileges(systemCode, dbTransaction);
|
340
|
+
systemLogin.sessionId = sessionId;
|
341
|
+
systemLogin.privileges = privileges;
|
342
|
+
userSession.systemLogins.map((system) =>
|
343
|
+
system.code === systemCode ? systemLogin : system,
|
344
|
+
);
|
345
|
+
} else {
|
346
|
+
// if not, add new system login into the userSession
|
347
|
+
const newLogin = {
|
348
|
+
id: systemCode,
|
349
|
+
code: systemCode,
|
350
|
+
sessionId: sessionId,
|
351
|
+
privileges: await this.getPrivileges(systemCode, dbTransaction),
|
352
|
+
};
|
353
|
+
userSession.systemLogins.push(newLogin);
|
354
|
+
}
|
355
|
+
// then update userSession inside the redis storage with 1 day duration of time-to-live
|
356
|
+
this._SessionService.setUserSession(
|
357
|
+
this.ObjectId,
|
358
|
+
userSession,
|
359
|
+
sessionName,
|
360
|
+
);
|
361
|
+
}
|
320
362
|
}
|
@@ -4,198 +4,100 @@ import {
|
|
4
4
|
CreatedAt,
|
5
5
|
DataType,
|
6
6
|
ForeignKey,
|
7
|
-
HasMany,
|
8
7
|
Model,
|
9
8
|
Table,
|
10
9
|
UpdatedAt,
|
11
10
|
} from 'sequelize-typescript';
|
12
|
-
|
13
|
-
import
|
14
|
-
import Staff from './staff.entity';
|
11
|
+
import { BuildingTypeEnum } from '../enum/building-type.enum';
|
12
|
+
import GroupModel from './group.entity';
|
15
13
|
|
16
14
|
@Table({
|
17
|
-
tableName: '
|
15
|
+
tableName: 'sso_Building',
|
18
16
|
timestamps: true,
|
19
|
-
createdAt: '
|
20
|
-
updatedAt: '
|
21
|
-
underscored: true,
|
17
|
+
createdAt: 'CreatedAt',
|
18
|
+
updatedAt: 'UpdatedAt',
|
22
19
|
})
|
23
|
-
export default class
|
20
|
+
export default class BuildingModel extends Model {
|
21
|
+
@ForeignKey(() => GroupModel)
|
24
22
|
@Column({
|
25
23
|
primaryKey: true,
|
26
24
|
allowNull: false,
|
27
|
-
|
28
|
-
type: DataType.INTEGER,
|
29
|
-
})
|
30
|
-
id: number;
|
31
|
-
|
32
|
-
@Column({
|
33
|
-
allowNull: true,
|
34
|
-
type: DataType.STRING,
|
35
|
-
field: 'name',
|
36
|
-
})
|
37
|
-
Name: string;
|
38
|
-
|
39
|
-
@Column({
|
40
|
-
allowNull: false,
|
41
|
-
type: DataType.STRING,
|
42
|
-
field: 'code',
|
25
|
+
type: DataType.STRING(10),
|
43
26
|
})
|
44
|
-
|
45
|
-
|
46
|
-
// @ForeignKey(() => BuildingType)
|
47
|
-
// @Column({
|
48
|
-
// allowNull: false,
|
49
|
-
// type: DataType.INTEGER,
|
50
|
-
// field: 'building_type_id',
|
51
|
-
// })
|
52
|
-
// BuildingTypeId: number;
|
27
|
+
GroupCode: string;
|
53
28
|
|
54
29
|
@Column({
|
55
30
|
allowNull: false,
|
56
|
-
type: DataType.STRING,
|
57
|
-
field: 'status',
|
31
|
+
type: DataType.STRING(100),
|
58
32
|
})
|
59
|
-
|
33
|
+
BuildingType: BuildingTypeEnum;
|
60
34
|
|
61
35
|
@Column({
|
62
36
|
allowNull: true,
|
63
|
-
type: DataType.STRING,
|
64
|
-
field: 'email',
|
37
|
+
type: DataType.STRING(200),
|
65
38
|
})
|
66
39
|
Email: string;
|
67
40
|
|
68
41
|
@Column({
|
69
42
|
allowNull: true,
|
70
|
-
type: DataType.STRING,
|
71
|
-
field: 'mobile',
|
43
|
+
type: DataType.STRING(20),
|
72
44
|
})
|
73
45
|
Mobile: string;
|
74
46
|
|
75
47
|
@Column({
|
76
48
|
allowNull: false,
|
77
|
-
type: DataType.STRING,
|
78
|
-
field: 'phone',
|
49
|
+
type: DataType.STRING(20),
|
79
50
|
})
|
80
51
|
Phone: string;
|
81
52
|
|
82
|
-
@Column({
|
83
|
-
allowNull: false,
|
84
|
-
type: DataType.STRING,
|
85
|
-
field: 'address',
|
86
|
-
})
|
87
|
-
Address: string;
|
88
|
-
|
89
53
|
@Column({
|
90
54
|
allowNull: true,
|
91
|
-
type: DataType.STRING,
|
92
|
-
field: 'latitude',
|
55
|
+
type: DataType.STRING(10),
|
93
56
|
})
|
94
|
-
|
57
|
+
Brand: string;
|
95
58
|
|
96
59
|
@Column({
|
97
|
-
allowNull:
|
98
|
-
type: DataType.
|
99
|
-
field: 'longitude',
|
60
|
+
allowNull: false,
|
61
|
+
type: DataType.INTEGER,
|
100
62
|
})
|
101
|
-
|
63
|
+
AreaManagerUserId: number;
|
102
64
|
|
103
65
|
@Column({
|
104
66
|
allowNull: false,
|
105
|
-
type: DataType.
|
106
|
-
field: 'postcode',
|
67
|
+
type: DataType.DATE,
|
107
68
|
})
|
108
|
-
|
109
|
-
|
110
|
-
// @ForeignKey(() => Country)
|
111
|
-
// @Column({
|
112
|
-
// allowNull: false,
|
113
|
-
// type: DataType.INTEGER,
|
114
|
-
// field: 'country_id',
|
115
|
-
// })
|
116
|
-
// CountryId: number;
|
69
|
+
OpeningDate: Date;
|
117
70
|
|
118
71
|
@Column({
|
119
72
|
allowNull: false,
|
120
|
-
type: DataType.
|
121
|
-
field: 'state',
|
73
|
+
type: DataType.DATE,
|
122
74
|
})
|
123
|
-
|
75
|
+
CeasedDate: Date;
|
124
76
|
|
125
77
|
@Column({
|
126
|
-
allowNull:
|
127
|
-
type: DataType.STRING,
|
128
|
-
field: 'city',
|
78
|
+
allowNull: true,
|
79
|
+
type: DataType.STRING(200),
|
129
80
|
})
|
130
|
-
|
81
|
+
OpeningHours: string;
|
131
82
|
|
132
|
-
@ForeignKey(() => User)
|
133
83
|
@Column({
|
134
|
-
allowNull:
|
84
|
+
allowNull: false,
|
135
85
|
type: DataType.INTEGER,
|
136
|
-
field: 'created_by_id',
|
137
86
|
})
|
138
87
|
CreatedById: number;
|
139
88
|
|
140
|
-
@ForeignKey(() => User)
|
141
89
|
@Column({
|
142
|
-
allowNull:
|
90
|
+
allowNull: false,
|
143
91
|
type: DataType.INTEGER,
|
144
|
-
field: 'updated_by_id',
|
145
92
|
})
|
146
93
|
UpdatedById: number;
|
147
94
|
|
148
|
-
@Column({
|
149
|
-
allowNull: true,
|
150
|
-
type: DataType.STRING,
|
151
|
-
field: 'brand',
|
152
|
-
})
|
153
|
-
Brand: string;
|
154
|
-
|
155
|
-
@Column({
|
156
|
-
allowNull: true,
|
157
|
-
type: DataType.STRING,
|
158
|
-
field: 'area_staff_id',
|
159
|
-
})
|
160
|
-
AreaStaffId: string;
|
161
|
-
|
162
|
-
@Column({
|
163
|
-
allowNull: true,
|
164
|
-
type: DataType.DATE,
|
165
|
-
field: 'opening_date',
|
166
|
-
})
|
167
|
-
OpeningDate: Date;
|
168
|
-
|
169
|
-
@Column({
|
170
|
-
allowNull: true,
|
171
|
-
type: DataType.DATE,
|
172
|
-
field: 'ceased_date',
|
173
|
-
})
|
174
|
-
CeasedDate: Date;
|
175
|
-
|
176
|
-
@Column({
|
177
|
-
allowNull: true,
|
178
|
-
type: DataType.STRING,
|
179
|
-
field: 'opening_hours',
|
180
|
-
})
|
181
|
-
OpeningHours: string;
|
182
|
-
|
183
|
-
@Column({
|
184
|
-
allowNull: true,
|
185
|
-
type: DataType.STRING,
|
186
|
-
field: 'image',
|
187
|
-
})
|
188
|
-
Image: string;
|
189
|
-
|
190
95
|
@CreatedAt
|
191
96
|
CreatedAt: Date;
|
192
97
|
|
193
98
|
@UpdatedAt
|
194
99
|
UpdatedAt: Date;
|
195
100
|
|
196
|
-
@BelongsTo(() =>
|
197
|
-
|
198
|
-
|
199
|
-
@BelongsTo(() => User, 'updated_by_id')
|
200
|
-
UpdatedBy: User;
|
101
|
+
@BelongsTo(() => GroupModel, 'GroupCode')
|
102
|
+
Group: GroupModel;
|
201
103
|
}
|