From 5924decae496524e3baf132a6c79fc81d784b1ba Mon Sep 17 00:00:00 2001 From: PARK BYUNG JUN Date: Sun, 7 Aug 2022 07:45:12 +0000 Subject: [PATCH] sessionId is added --- src/app/core/nats/services/nats.service.ts | 18 +++++++++++++---- .../services/web-storage.service.ts | 1 + .../member/user/components/list.component.ts | 20 ++----------------- .../sign-in/components/sign-in.component.ts | 2 ++ 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/app/core/nats/services/nats.service.ts b/src/app/core/nats/services/nats.service.ts index 263bdcf..3f18205 100644 --- a/src/app/core/nats/services/nats.service.ts +++ b/src/app/core/nats/services/nats.service.ts @@ -1,4 +1,4 @@ -import { Inject, Injectable, Type } from '@angular/core'; +import { Inject, Injectable, OnInit, Type } from '@angular/core'; import { DOCUMENT } from '@angular/common'; import * as jspb from 'google-protobuf'; @@ -9,7 +9,7 @@ import { Client } from 'app/modules/protobuf/models/core/network_pb'; import { ModuleConfig } from '../config/module-config'; import { _MODULE_CONFIG } from '../config/token'; -import { Router } from '@angular/router'; +import { WebSessionStorageService } from 'app/core/web-storage/services/web-session-storage.service'; type DeserializeConstructor = { new (): T; @@ -30,9 +30,12 @@ export class NatsService { */ constructor( @Inject(_MODULE_CONFIG) private __config: ModuleConfig, - @Inject(DOCUMENT) private __document: Document + @Inject(DOCUMENT) private __document: Document, + private __webSessionStorageService: WebSessionStorageService ) {} + ngOnInit(): void {} + // ----------------------------------------------------------------------------------------------------- // @ Accessors // ----------------------------------------------------------------------------------------------------- @@ -54,6 +57,13 @@ export class NatsService { .then((conn) => { console.log('NATS connected', conn.info?.client_ip); this.__conn = conn; + + this.__webSessionStorageService + .watch('SESSION_ID') + .subscribe((sessionId) => { + console.log('sessionId in NatsService', sessionId); + }); + resolve(); }) .catch((e) => { @@ -71,7 +81,7 @@ export class NatsService { return new Promise((resolve, reject) => { let c = new Client(); c.setClientIp(this.__conn?.info?.client_ip + ''); - c.setSessionId(''); + c.setSessionId(this.__webSessionStorageService.get('SESSION_ID')); c.setSiteUrl(this.__document.location.hostname); let _opts: nats.RequestOptions = !!opts ? opts : { timeout: 3000 }; diff --git a/src/app/core/web-storage/services/web-storage.service.ts b/src/app/core/web-storage/services/web-storage.service.ts index c963608..eee9e0e 100644 --- a/src/app/core/web-storage/services/web-storage.service.ts +++ b/src/app/core/web-storage/services/web-storage.service.ts @@ -60,6 +60,7 @@ export abstract class WebStorageService { this.__storage.setItem(key, JSON.stringify(value)); if (!this.__subjects.has(key)) { this.__subjects.set(key, new BehaviorSubject(value)); + (this.__subjects.get(key) as BehaviorSubject).next(value); } else { (this.__subjects.get(key) as BehaviorSubject).next(value); } diff --git a/src/app/modules/admin/member/user/components/list.component.ts b/src/app/modules/admin/member/user/components/list.component.ts index e06e603..d7c2c27 100644 --- a/src/app/modules/admin/member/user/components/list.component.ts +++ b/src/app/modules/admin/member/user/components/list.component.ts @@ -8,24 +8,10 @@ import { ViewChild, ViewEncapsulation, } from '@angular/core'; -import { - FormBuilder, - FormControl, - FormGroup, - Validators, -} from '@angular/forms'; -import { MatCheckboxChange } from '@angular/material/checkbox'; +import { FormBuilder, FormControl } from '@angular/forms'; import { MatPaginator } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; -import { - debounceTime, - map, - merge, - Observable, - Subject, - switchMap, - takeUntil, -} from 'rxjs'; +import { map, merge, Observable, Subject, switchMap, takeUntil } from 'rxjs'; import { fuseAnimations } from '@fuse/animations'; import { FuseConfirmationService } from '@fuse/services/confirmation'; @@ -197,8 +183,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { */ __onClickSearch(): void { this.__isSearchOpened = !this.__isSearchOpened; - - console.log('kkkk', this._identityService.captcha()); } /** diff --git a/src/app/modules/auth/sign-in/components/sign-in.component.ts b/src/app/modules/auth/sign-in/components/sign-in.component.ts index acb6604..638808e 100644 --- a/src/app/modules/auth/sign-in/components/sign-in.component.ts +++ b/src/app/modules/auth/sign-in/components/sign-in.component.ts @@ -5,6 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { fuseAnimations } from '@fuse/animations'; import { FuseAlertType } from '@fuse/components/alert'; import { AuthService } from 'app/core/auth/auth.service'; +import { WebSessionStorageService } from 'app/core/web-storage/services/web-session-storage.service'; import { IdentityService } from 'app/modules/polyglot/member/services/identity.service'; import { CaptchaResponse } from 'app/modules/protobuf/c2se/common/identity_pb'; @@ -36,6 +37,7 @@ export class AuthSignInComponent implements OnInit { private _formBuilder: FormBuilder, private _router: Router, private _identityService: IdentityService, + private __webSessionStorageService: WebSessionStorageService, private _sanitizer: DomSanitizer ) {}