@tomei/sso 0.8.8 → 0.8.10
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.js +33 -17
- package/dist/src/components/login-user/login-user.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -11
- package/src/components/login-user/login-user.ts +37 -25
- package/src/index.ts +1 -1
- package/dist/src/prisma-client/__mocks__/prisma.d.ts +0 -3
- package/dist/src/prisma-client/__mocks__/prisma.js +0 -14
- package/dist/src/prisma-client/__mocks__/prisma.js.map +0 -1
- package/dist/src/prisma-client/client.d.ts +0 -3
- package/dist/src/prisma-client/client.js +0 -6
- package/dist/src/prisma-client/client.js.map +0 -1
- package/dist/src/prisma-client/index.d.ts +0 -1
- package/dist/src/prisma-client/index.js +0 -18
- package/dist/src/prisma-client/index.js.map +0 -1
- package/prisma/migrations/0_init/migration.sql +0 -512
- package/prisma/migrations/20230528161352_create_user_user_group_and_add_new_column/migration.sql +0 -35
- package/prisma/migrations/20230606091407_create_login_histories_table/migration.sql +0 -17
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -519
- package/src/prisma-client/__mocks__/prisma.ts +0 -15
- package/src/prisma-client/client.ts +0 -3
- package/src/prisma-client/index.ts +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tomei/sso",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.10",
|
4
4
|
"description": "Tomei SSO Package",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"scripts": {
|
@@ -57,25 +57,21 @@
|
|
57
57
|
"access": "public"
|
58
58
|
},
|
59
59
|
"peerDependencies": {
|
60
|
-
"@
|
61
|
-
"@tomei/general": "^0.3.0",
|
60
|
+
"@tomei/general": "^0.4.0",
|
62
61
|
"@types/jest": "^29.5.2",
|
63
62
|
"argon2": "^0.30.3",
|
64
63
|
"cls-hooked": "^4.2.2",
|
65
64
|
"nodemailer": "^6.9.3",
|
66
|
-
"
|
67
|
-
"
|
65
|
+
"redis": "^4.6.7",
|
66
|
+
"@tomei/mailer": "^0.5.2",
|
67
|
+
"reflect-metadata": "^0.1.13",
|
68
|
+
"sequelize": "^6.32.1",
|
69
|
+
"sequelize-typescript": "^2.1.5"
|
68
70
|
},
|
69
71
|
"lint-staged": {
|
70
72
|
"*/**/*.{js,ts,tsx}": [
|
71
73
|
"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
72
74
|
"eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
|
73
75
|
]
|
74
|
-
},
|
75
|
-
"dependencies": {
|
76
|
-
"@tomei/mailer": "^0.1.3",
|
77
|
-
"reflect-metadata": "^0.1.13",
|
78
|
-
"sequelize": "^6.32.1",
|
79
|
-
"sequelize-typescript": "^2.1.5"
|
80
76
|
}
|
81
77
|
}
|
@@ -11,7 +11,7 @@ import { PasswordHashService } from '../password-hash/password-hash.service';
|
|
11
11
|
import { SessionService } from '../../session/session.service';
|
12
12
|
import { UserGroupRepository } from '../user-group/user-group.repository';
|
13
13
|
import * as nodemailer from 'nodemailer';
|
14
|
-
import {
|
14
|
+
import { SMTPMailer } from '@tomei/mailer';
|
15
15
|
import { ISystemLogin } from '../../../src/interfaces/system-login.interface';
|
16
16
|
import Staff from '../../models/staff.entity';
|
17
17
|
import SystemPrivilege from '../../models/system-privilege.entity';
|
@@ -19,7 +19,7 @@ import LoginHistory from '../../models/login-history.entity';
|
|
19
19
|
import GroupSystemPrivilege from '../../models/group-system-privilege.entity';
|
20
20
|
import GroupRolePrivilege from '../../models/group-role-privilege.entity';
|
21
21
|
import UserGroup from '../../models/user-group.entity';
|
22
|
-
|
22
|
+
|
23
23
|
export class LoginUser extends ObjectBase implements IPerson {
|
24
24
|
FullName: string;
|
25
25
|
IDNo: string;
|
@@ -100,12 +100,6 @@ export class LoginUser extends ObjectBase implements IPerson {
|
|
100
100
|
{
|
101
101
|
model: Staff,
|
102
102
|
},
|
103
|
-
// {
|
104
|
-
// model: SystemPrivilege,
|
105
|
-
// Include: {
|
106
|
-
// model: SystemPrivilege,
|
107
|
-
// },
|
108
|
-
// },
|
109
103
|
],
|
110
104
|
});
|
111
105
|
|
@@ -136,8 +130,37 @@ export class LoginUser extends ObjectBase implements IPerson {
|
|
136
130
|
): Promise<string> {
|
137
131
|
try {
|
138
132
|
//validate email
|
139
|
-
if (this.Email !== email) {
|
133
|
+
if (this.ObjectId && this.Email !== email) {
|
140
134
|
throw new Error('Invalid credentials.');
|
135
|
+
} else {
|
136
|
+
const user = await LoginUser._Repository.findOne({
|
137
|
+
where: {
|
138
|
+
Email: email,
|
139
|
+
},
|
140
|
+
include: [
|
141
|
+
{
|
142
|
+
model: Staff,
|
143
|
+
},
|
144
|
+
],
|
145
|
+
});
|
146
|
+
|
147
|
+
const userInfo: IUserInfo = {
|
148
|
+
ObjectId: user.id.toString(),
|
149
|
+
FullName: user.Staff.FullName,
|
150
|
+
IDNo: user.Staff.IdNo,
|
151
|
+
ContactNo: user.Staff.Mobile,
|
152
|
+
Email: user.Staff.Email,
|
153
|
+
Password: user.Password,
|
154
|
+
staffs: user.Staff,
|
155
|
+
};
|
156
|
+
|
157
|
+
this.ObjectId = userInfo.ObjectId;
|
158
|
+
this.FullName = userInfo.FullName;
|
159
|
+
this.IDNo = userInfo.IDNo;
|
160
|
+
this.Email = userInfo.Email;
|
161
|
+
this.ContactNo = userInfo.ContactNo;
|
162
|
+
this.Password = userInfo.Password;
|
163
|
+
this.staffs = userInfo.staffs;
|
141
164
|
}
|
142
165
|
|
143
166
|
//validate password
|
@@ -252,23 +275,12 @@ export class LoginUser extends ObjectBase implements IPerson {
|
|
252
275
|
}
|
253
276
|
|
254
277
|
if (gotPreviousLogins && !ipFound) {
|
255
|
-
const
|
256
|
-
|
257
|
-
const
|
258
|
-
const EMAIL_PASSWORD = process.env.EMAIL_PASSWORD || '';
|
259
|
-
|
260
|
-
const mailer = new Mailer(nodemailer, {
|
261
|
-
host: SMTP_HOST,
|
262
|
-
port: Number(SMTP_PORT),
|
263
|
-
secure: Number(SMTP_PORT) === 465,
|
264
|
-
auth: {
|
265
|
-
user: EMAIL_SENDER,
|
266
|
-
pass: EMAIL_PASSWORD,
|
267
|
-
},
|
268
|
-
});
|
278
|
+
const EMAIL_SENDER =
|
279
|
+
process.env.EMAIL_SENDER || 'itd-system@tomei.com.my';
|
280
|
+
const transporter = new SMTPMailer();
|
269
281
|
|
270
|
-
await
|
271
|
-
from:
|
282
|
+
await transporter.sendMail({
|
283
|
+
from: EMAIL_SENDER,
|
272
284
|
to: this.Email,
|
273
285
|
subject: 'New Login Alert',
|
274
286
|
html: `<p>Dear ${this.FullName},</p>
|
package/src/index.ts
CHANGED
@@ -1,3 +0,0 @@
|
|
1
|
-
import { PrismaClient } from '@prisma/client';
|
2
|
-
import { DeepMockProxy } from 'jest-mock-extended';
|
3
|
-
export declare const prismaMock: DeepMockProxy<PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import(".prisma/client").Prisma.RejectOnNotFound | import(".prisma/client").Prisma.RejectPerOperation | undefined>>;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.prismaMock = void 0;
|
4
|
-
const jest_mock_extended_1 = require("jest-mock-extended");
|
5
|
-
const client_1 = require("../client");
|
6
|
-
jest.mock('../client', () => ({
|
7
|
-
__esModule: true,
|
8
|
-
default: (0, jest_mock_extended_1.mockDeep)(),
|
9
|
-
}));
|
10
|
-
beforeEach(() => {
|
11
|
-
(0, jest_mock_extended_1.mockReset)(exports.prismaMock);
|
12
|
-
});
|
13
|
-
exports.prismaMock = client_1.default;
|
14
|
-
//# sourceMappingURL=prisma.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"prisma.js","sourceRoot":"","sources":["../../../../src/prisma-client/__mocks__/prisma.ts"],"names":[],"mappings":";;;AACA,2DAAwE;AAExE,sCAA+B;AAE/B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAA,6BAAQ,GAAgB;CAClC,CAAC,CAAC,CAAC;AAEJ,UAAU,CAAC,GAAG,EAAE;IACd,IAAA,8BAAS,EAAC,kBAAU,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC;AAEU,QAAA,UAAU,GAAG,gBAAgD,CAAC"}
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { PrismaClient } from '@prisma/client';
|
2
|
-
declare const prisma: PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import(".prisma/client").Prisma.RejectOnNotFound | import(".prisma/client").Prisma.RejectPerOperation | undefined>;
|
3
|
-
export default prisma;
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/prisma-client/client.ts"],"names":[],"mappings":";;AAAA,2CAA8C;AAC9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAClC,kBAAe,MAAM,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './client';
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./client"), exports);
|
18
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prisma-client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}
|