login refactoring

This commit is contained in:
leejinho 2020-01-10 17:09:08 +09:00
parent 5530f769c6
commit 1cb5af9174
3 changed files with 17 additions and 5 deletions

View File

@ -3,7 +3,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Company } from '@ucap-webmessenger/api-external';
import { ServerErrorCode } from '@ucap-webmessenger/protocol';
import { ServerErrorCode, ProtocolService } from '@ucap-webmessenger/protocol';
import * as AppStore from '@app/store';
import * as AuthenticationStore from '@app/store/account/authentication';
@ -31,6 +31,8 @@ import {
} from '@ucap-webmessenger/web-storage';
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
import { LogoutInfo, KEY_LOGOUT_INFO } from '@app/types';
import { AppAuthenticationService } from '@app/services/authentication.service';
import { logoutInitialize } from '@app/store/account/authentication';
@Component({
selector: 'app-page-account-login',
@ -84,8 +86,10 @@ export class LoginPageComponent implements OnInit, OnDestroy {
private store: Store<any>,
private router: Router,
private dialogService: DialogService,
private protocolService: ProtocolService,
private localStorageService: LocalStorageService,
private sessionStorageService: SessionStorageService
private sessionStorageService: SessionStorageService,
private appAuthenticationService: AppAuthenticationService
) {
this.useRememberMe =
environment.productConfig.authentication.rememberMe.use;
@ -101,6 +105,10 @@ export class LoginPageComponent implements OnInit, OnDestroy {
}
ngOnInit(): void {
// this.appAuthenticationService.logout();
this.protocolService.disconnect();
this.store.dispatch(logoutInitialize());
this.rotateInfomationIntervalObject = setInterval(() => {
this.rotateInfomationIndex =
(this.rotateInfomationIndex + 1) % this.rotateInfomation.length;
@ -179,7 +187,7 @@ export class LoginPageComponent implements OnInit, OnDestroy {
!!personLogout.reasonCode &&
personLogout.reasonCode === ServerErrorCode.ERRCD_DUPLICATE
) {
const result = await this.dialogService.open<
const result = this.dialogService.open<
AlertDialogComponent,
AlertDialogData,
AlertDialogResult

View File

@ -12,7 +12,8 @@ import {
KEY_VER_INFO,
KEY_URL_INFO,
KEY_LOGOUT_INFO,
LogoutInfo
LogoutInfo,
KEY_AUTH_INFO
} from '../types';
import { PasswordUtil } from '@ucap-webmessenger/pi';
@ -106,5 +107,6 @@ export class AppAuthenticationService {
this.sessionStorageService.remove(KEY_VER_INFO);
this.sessionStorageService.remove(KEY_LOGIN_INFO);
this.sessionStorageService.remove(KEY_URL_INFO);
this.sessionStorageService.remove(KEY_AUTH_INFO);
}
}

View File

@ -150,7 +150,9 @@ export class ProtocolService {
}
public disconnect(): void {
this.messagesSubscription.unsubscribe();
if (!!this.messagesSubscription) {
this.messagesSubscription.unsubscribe();
}
}
public get serverMessage(): Observable<ProtocolMessage> {