rez_core 6.5.11 → 6.5.13
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/module/user/entity/user-session.entity.js +2 -3
- package/dist/module/user/entity/user-session.entity.js.map +1 -1
- package/dist/module/user/repository/userSession.repository.d.ts +1 -0
- package/dist/module/user/repository/userSession.repository.js +3 -0
- package/dist/module/user/repository/userSession.repository.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +1 -0
- package/dist/module/user/service/user-session.service.js +4 -1
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/user/entity/user-session.entity.ts +3 -4
- package/src/module/user/repository/userSession.repository.ts +5 -1
- package/src/module/user/service/user-session.service.ts +8 -3
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
1
|
+
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
2
|
|
|
3
3
|
@Entity({ name: 'sso_user_session' })
|
|
4
4
|
export class UserSession {
|
|
@@ -19,9 +19,8 @@ export class UserSession {
|
|
|
19
19
|
})
|
|
20
20
|
login_id: string;
|
|
21
21
|
|
|
22
|
-
@
|
|
23
|
-
name: 'login_time'
|
|
24
|
-
nullable: true,
|
|
22
|
+
@CreateDateColumn({
|
|
23
|
+
name: 'login_time'
|
|
25
24
|
})
|
|
26
25
|
login_time: Date;
|
|
27
26
|
|
|
@@ -8,7 +8,7 @@ export class UserSessionRepository {
|
|
|
8
8
|
constructor(
|
|
9
9
|
@InjectRepository(UserSession)
|
|
10
10
|
private userSessionRepo: Repository<UserSession>,
|
|
11
|
-
) {}
|
|
11
|
+
) { }
|
|
12
12
|
|
|
13
13
|
async findBySessionKey(sessionKey: string): Promise<UserSession | null> {
|
|
14
14
|
return this.userSessionRepo.findOne({ where: { session_key: sessionKey } });
|
|
@@ -24,6 +24,10 @@ export class UserSessionRepository {
|
|
|
24
24
|
return this.userSessionRepo.save(session);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
async fetchUserFcmToken(user_id: number) {
|
|
28
|
+
return await this.userSessionRepo.findOne({ where: { user_id }, select: ['fcm_token'], order: { login_time: 'DESC' } });
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
async logoutSession(sessionKey: string): Promise<void> {
|
|
28
32
|
await this.userSessionRepo.update(
|
|
29
33
|
{ session_key: sessionKey },
|
|
@@ -23,15 +23,16 @@ export class UserSessionService {
|
|
|
23
23
|
@InjectRepository(UserRoleMapping)
|
|
24
24
|
private readonly userRoleMappingRepository: Repository<UserRoleMapping>,
|
|
25
25
|
private readonly reflectionHelper: ReflectionHelper,
|
|
26
|
-
) {}
|
|
27
|
-
|
|
26
|
+
) { }
|
|
27
|
+
|
|
28
|
+
async createSession(user, app_id?: number, accessInfo?: any, appcode?: string) {
|
|
28
29
|
const sessionToken = this.clockIDGenService.idGenerator('SES');
|
|
29
30
|
|
|
30
31
|
const userSession: any = new UserSession();
|
|
31
32
|
userSession.user_id = user.id;
|
|
32
33
|
userSession.session_key = sessionToken;
|
|
33
34
|
userSession.is_session_loggedout = 0;
|
|
34
|
-
userSession.login_time = new Date();
|
|
35
|
+
// userSession.login_time = new Date(); -- Changed login_time to be auto generated by typeorm
|
|
35
36
|
|
|
36
37
|
const expiryTokenInHours = this.configService.get('TOKEN_EXPIRY') || 1;
|
|
37
38
|
userSession.expiry_date = new Date(
|
|
@@ -72,6 +73,10 @@ export class UserSessionService {
|
|
|
72
73
|
await this.userSessionRepository.saveSession(userSession);
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
async fetchUserFcmToken(user_id: number) {
|
|
77
|
+
return await this.userSessionRepository.fetchUserFcmToken(user_id);
|
|
78
|
+
};
|
|
79
|
+
|
|
75
80
|
|
|
76
81
|
async switchCurrentLevelService(
|
|
77
82
|
currentUser: any,
|