sessionId is added

This commit is contained in:
병준 박 2022-08-07 07:45:12 +00:00
parent 6fab831ef5
commit 5924decae4
4 changed files with 19 additions and 22 deletions

View File

@ -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 { DOCUMENT } from '@angular/common';
import * as jspb from 'google-protobuf'; 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 { ModuleConfig } from '../config/module-config';
import { _MODULE_CONFIG } from '../config/token'; 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<T> = { type DeserializeConstructor<T> = {
new (): T; new (): T;
@ -30,9 +30,12 @@ export class NatsService {
*/ */
constructor( constructor(
@Inject(_MODULE_CONFIG) private __config: ModuleConfig, @Inject(_MODULE_CONFIG) private __config: ModuleConfig,
@Inject(DOCUMENT) private __document: Document @Inject(DOCUMENT) private __document: Document,
private __webSessionStorageService: WebSessionStorageService
) {} ) {}
ngOnInit(): void {}
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
// @ Accessors // @ Accessors
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -54,6 +57,13 @@ export class NatsService {
.then((conn) => { .then((conn) => {
console.log('NATS connected', conn.info?.client_ip); console.log('NATS connected', conn.info?.client_ip);
this.__conn = conn; this.__conn = conn;
this.__webSessionStorageService
.watch('SESSION_ID')
.subscribe((sessionId) => {
console.log('sessionId in NatsService', sessionId);
});
resolve(); resolve();
}) })
.catch((e) => { .catch((e) => {
@ -71,7 +81,7 @@ export class NatsService {
return new Promise<R>((resolve, reject) => { return new Promise<R>((resolve, reject) => {
let c = new Client(); let c = new Client();
c.setClientIp(this.__conn?.info?.client_ip + ''); c.setClientIp(this.__conn?.info?.client_ip + '');
c.setSessionId(''); c.setSessionId(this.__webSessionStorageService.get('SESSION_ID'));
c.setSiteUrl(this.__document.location.hostname); c.setSiteUrl(this.__document.location.hostname);
let _opts: nats.RequestOptions = !!opts ? opts : { timeout: 3000 }; let _opts: nats.RequestOptions = !!opts ? opts : { timeout: 3000 };

View File

@ -60,6 +60,7 @@ export abstract class WebStorageService {
this.__storage.setItem(key, JSON.stringify(value)); this.__storage.setItem(key, JSON.stringify(value));
if (!this.__subjects.has(key)) { if (!this.__subjects.has(key)) {
this.__subjects.set(key, new BehaviorSubject<any>(value)); this.__subjects.set(key, new BehaviorSubject<any>(value));
(this.__subjects.get(key) as BehaviorSubject<any>).next(value);
} else { } else {
(this.__subjects.get(key) as BehaviorSubject<any>).next(value); (this.__subjects.get(key) as BehaviorSubject<any>).next(value);
} }

View File

@ -8,24 +8,10 @@ import {
ViewChild, ViewChild,
ViewEncapsulation, ViewEncapsulation,
} from '@angular/core'; } from '@angular/core';
import { import { FormBuilder, FormControl } from '@angular/forms';
FormBuilder,
FormControl,
FormGroup,
Validators,
} from '@angular/forms';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { MatPaginator } from '@angular/material/paginator'; import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort'; import { MatSort } from '@angular/material/sort';
import { import { map, merge, Observable, Subject, switchMap, takeUntil } from 'rxjs';
debounceTime,
map,
merge,
Observable,
Subject,
switchMap,
takeUntil,
} from 'rxjs';
import { fuseAnimations } from '@fuse/animations'; import { fuseAnimations } from '@fuse/animations';
import { FuseConfirmationService } from '@fuse/services/confirmation'; import { FuseConfirmationService } from '@fuse/services/confirmation';
@ -197,8 +183,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
*/ */
__onClickSearch(): void { __onClickSearch(): void {
this.__isSearchOpened = !this.__isSearchOpened; this.__isSearchOpened = !this.__isSearchOpened;
console.log('kkkk', this._identityService.captcha());
} }
/** /**

View File

@ -5,6 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { fuseAnimations } from '@fuse/animations'; import { fuseAnimations } from '@fuse/animations';
import { FuseAlertType } from '@fuse/components/alert'; import { FuseAlertType } from '@fuse/components/alert';
import { AuthService } from 'app/core/auth/auth.service'; 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 { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
import { CaptchaResponse } from 'app/modules/protobuf/c2se/common/identity_pb'; import { CaptchaResponse } from 'app/modules/protobuf/c2se/common/identity_pb';
@ -36,6 +37,7 @@ export class AuthSignInComponent implements OnInit {
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _router: Router, private _router: Router,
private _identityService: IdentityService, private _identityService: IdentityService,
private __webSessionStorageService: WebSessionStorageService,
private _sanitizer: DomSanitizer private _sanitizer: DomSanitizer
) {} ) {}