@tomei/sso 0.15.10 → 0.16.1
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/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.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/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.js +85 -25
- package/dist/src/models/user.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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} +1 -1
- package/migrations/{05-create-login-history-table.js → 20240314080605-create-login-history-table.js} +1 -1
- package/package.json +3 -2
- 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 +1 -1
- package/src/enum/index.ts +1 -0
- package/src/enum/yn.enum.ts +4 -0
- package/src/models/user.entity.ts +160 -110
@@ -0,0 +1,108 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/** @type {import('sequelize-cli').Migration} */
|
4
|
+
module.exports = {
|
5
|
+
async up(queryInterface, Sequelize) {
|
6
|
+
await queryInterface.createTable('sso_User', {
|
7
|
+
UserId: {
|
8
|
+
primaryKey: true,
|
9
|
+
type: Sequelize.INTEGER,
|
10
|
+
allowNull: false,
|
11
|
+
autoIncrement: true,
|
12
|
+
},
|
13
|
+
Email: {
|
14
|
+
type: Sequelize.STRING,
|
15
|
+
allowNull: false,
|
16
|
+
unique: true,
|
17
|
+
},
|
18
|
+
Password: {
|
19
|
+
type: Sequelize.STRING,
|
20
|
+
allowNull: false,
|
21
|
+
},
|
22
|
+
Status: {
|
23
|
+
type: Sequelize.STRING,
|
24
|
+
allowNull: false,
|
25
|
+
},
|
26
|
+
DefaultPasswordChangedYN: {
|
27
|
+
type: Sequelize.CHAR(1),
|
28
|
+
allowNull: true,
|
29
|
+
},
|
30
|
+
FirstLoginAt: {
|
31
|
+
type: Sequelize.DATE,
|
32
|
+
allowNull: true,
|
33
|
+
},
|
34
|
+
LastLoginAt: {
|
35
|
+
type: Sequelize.DATE,
|
36
|
+
allowNull: true,
|
37
|
+
},
|
38
|
+
MFAEnabled: {
|
39
|
+
type: Sequelize.TINYINT,
|
40
|
+
allowNull: true,
|
41
|
+
},
|
42
|
+
MFAConfig: {
|
43
|
+
type: Sequelize.TEXT,
|
44
|
+
allowNull: true,
|
45
|
+
},
|
46
|
+
RecoveryEmail: {
|
47
|
+
type: Sequelize.STRING,
|
48
|
+
allowNull: true,
|
49
|
+
},
|
50
|
+
FailedLoginAttemptCount: {
|
51
|
+
type: Sequelize.INTEGER,
|
52
|
+
allowNull: false,
|
53
|
+
},
|
54
|
+
LastFailedLoginAt: {
|
55
|
+
type: Sequelize.DATE,
|
56
|
+
allowNull: true,
|
57
|
+
},
|
58
|
+
LastPasswordChangedAt: {
|
59
|
+
type: Sequelize.DATE,
|
60
|
+
allowNull: true,
|
61
|
+
},
|
62
|
+
NeedToChangePasswordYN: {
|
63
|
+
type: Sequelize.CHAR(1),
|
64
|
+
allowNull: true,
|
65
|
+
},
|
66
|
+
CreatedAt: {
|
67
|
+
allowNull: false,
|
68
|
+
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3)'),
|
69
|
+
type: Sequelize.DATE,
|
70
|
+
},
|
71
|
+
CreatedById: {
|
72
|
+
type: Sequelize.INTEGER,
|
73
|
+
allowNull: true,
|
74
|
+
references: {
|
75
|
+
model: 'sso_User',
|
76
|
+
key: 'UserId',
|
77
|
+
},
|
78
|
+
onDelete: 'CASCADE',
|
79
|
+
onUpdate: 'CASCADE',
|
80
|
+
},
|
81
|
+
UpdatedAt: {
|
82
|
+
allowNull: false,
|
83
|
+
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)'),
|
84
|
+
type: Sequelize.DATE,
|
85
|
+
},
|
86
|
+
UpdatedById: {
|
87
|
+
type: Sequelize.INTEGER,
|
88
|
+
allowNull: true,
|
89
|
+
references: {
|
90
|
+
model: 'sso_User',
|
91
|
+
key: 'UserId',
|
92
|
+
},
|
93
|
+
onDelete: 'CASCADE',
|
94
|
+
onUpdate: 'CASCADE',
|
95
|
+
},
|
96
|
+
|
97
|
+
});
|
98
|
+
},
|
99
|
+
|
100
|
+
async down(queryInterface, Sequelize) {
|
101
|
+
/**
|
102
|
+
* Add reverting commands here.
|
103
|
+
*
|
104
|
+
* Example:
|
105
|
+
* await queryInterface.dropTable('users');
|
106
|
+
*/
|
107
|
+
}
|
108
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tomei/sso",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.16.1",
|
4
4
|
"description": "Tomei SSO Package",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
@@ -46,6 +46,7 @@
|
|
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",
|
49
50
|
"ts-jest": "^29.1.0",
|
50
51
|
"ts-node": "^10.9.1",
|
51
52
|
"tsc-watch": "^5.0.3",
|
@@ -58,7 +59,7 @@
|
|
58
59
|
},
|
59
60
|
"peerDependencies": {
|
60
61
|
"@tomei/config": "^0.3.9",
|
61
|
-
"@tomei/general": "^0.10.
|
62
|
+
"@tomei/general": "^0.10.6",
|
62
63
|
"@tomei/mailer": "^0.5.11",
|
63
64
|
"@types/jest": "^29.5.2",
|
64
65
|
"argon2": "^0.30.3",
|
@@ -1,14 +1,19 @@
|
|
1
1
|
import { BuildingTypeRepository } from '../building-type/building-type.repository';
|
2
2
|
import { BuildingRepository } from './building.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 BuildingType from '../../models/building-type.entity';
|
7
7
|
import Country from '../../models/country.entity';
|
8
|
+
import { ObjectBase } from '@tomei/general';
|
8
9
|
|
9
|
-
export class Building {
|
10
|
+
export class Building extends ObjectBase {
|
10
11
|
// implement all attributes from sso_buildings table
|
11
|
-
|
12
|
+
ObjectId: string;
|
13
|
+
ObjectName: string;
|
14
|
+
ObjectType = 'Building';
|
15
|
+
TableName = 'sso_buildings';
|
16
|
+
private _id: number;
|
12
17
|
name: string;
|
13
18
|
code: string;
|
14
19
|
building_type_id: number;
|
@@ -39,7 +44,17 @@ export class Building {
|
|
39
44
|
private static _Repo = new BuildingRepository();
|
40
45
|
private _RepoBuildingType = new BuildingTypeRepository();
|
41
46
|
|
47
|
+
set id(id: number) {
|
48
|
+
this._id = id;
|
49
|
+
this.ObjectId = id.toString();
|
50
|
+
}
|
51
|
+
|
52
|
+
get id() {
|
53
|
+
return this._id;
|
54
|
+
}
|
55
|
+
|
42
56
|
private constructor(buildingInfo) {
|
57
|
+
super();
|
43
58
|
if (buildingInfo) {
|
44
59
|
this.id = buildingInfo.id;
|
45
60
|
this.name = buildingInfo.Name;
|
@@ -1,9 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
import { YN } from '../../../enum/yn.enum';
|
2
|
+
|
3
|
+
export interface IUserInfo {
|
4
|
+
FullName: string;
|
5
|
+
IDNo: string;
|
6
|
+
Email: string;
|
7
|
+
ContactNo: string;
|
8
|
+
UserId: number;
|
9
|
+
Password: string;
|
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
|
+
}
|