@tomei/sso 0.10.0 → 0.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.10.0",
3
+ "version": "0.11.4",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -7,7 +7,6 @@ import { SystemAccessRepository } from '../system-access/system-access.repositor
7
7
  import { LoginHistoryRepository } from '../login-history/login-history.repository';
8
8
  import { UserUserGroupRepository } from '../user-user-group/user-user-group.repository';
9
9
  import { PasswordHashService } from '../password-hash/password-hash.service';
10
- import { SessionService } from '../../session/session.service';
11
10
  import { UserGroupRepository } from '../user-group/user-group.repository';
12
11
  import { SMTPMailer } from '@tomei/mailer';
13
12
  import { ISystemLogin } from '../../../src/interfaces/system-login.interface';
@@ -101,6 +100,10 @@ export class LoginUser extends LoginUserBase {
101
100
  ],
102
101
  });
103
102
 
103
+ if (!user) {
104
+ throw new Error('Invalid credentials.');
105
+ }
106
+
104
107
  if (user) {
105
108
  const userInfo: IUserInfo = {
106
109
  ObjectId: user.id.toString(),
@@ -221,15 +224,13 @@ export class LoginUser extends LoginUserBase {
221
224
 
222
225
  // record new login history
223
226
  await LoginUser._LoginHistoryRepository.create({
224
- data: {
225
- userId: this.ObjectId,
226
- systemId: system.id,
227
- originIp: ipAddress,
228
- createdAt: new Date(),
229
- },
227
+ UserId: this.ObjectId,
228
+ SystemId: system.id,
229
+ OriginIp: ipAddress,
230
+ CreatedAt: new Date(),
230
231
  });
231
232
 
232
- return sessionId;
233
+ return `${this.ObjectId}:${sessionId}`;
233
234
  } catch (error) {
234
235
  throw error;
235
236
  }
@@ -263,8 +264,8 @@ export class LoginUser extends LoginUserBase {
263
264
  try {
264
265
  const userLogins = await LoginUser._LoginHistoryRepository.findAll({
265
266
  where: {
266
- userId: userId,
267
- systemId: systemId,
267
+ UserId: userId,
268
+ SystemId: systemId,
268
269
  },
269
270
  });
270
271
 
@@ -45,9 +45,8 @@ export class SessionService implements ISessionService {
45
45
 
46
46
  async refreshDuration(userid: string): Promise<void> {
47
47
  try {
48
- const key = `tomei-sid:${userid}`;
49
48
  const userSession = await this.retrieveUserSession(userid);
50
- await this.setUserSession(key, userSession);
49
+ await this.setUserSession(userid, userSession);
51
50
  } catch (error) {
52
51
  throw error;
53
52
  }