diff --git a/package-lock.json b/package-lock.json index 95cabfa..9832026 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2377,9 +2377,8 @@ "dev": true }, "@ucap/ng-store-authentication": { - "version": "file:pack/ucap-ng-store-authentication-0.0.2.tgz", - "integrity": "sha512-ohUQItPCnNKZrnBoH0lFNFSAHtZkRAfGnLTBXBa4+xapSKGO6h2XaWaszql+ava/q7nelFkNFmYHej0wVLWmdw==", - "dev": true + "version": "file:pack/ucap-ng-store-authentication-0.0.3.tgz", + "integrity": "sha512-qgtPOxPDBWLytKNl4KxPJiAt+EhWk+7JZMiKGlrs/VqXgys4UHVv/OJhOC46d0ZBunswUsiEw4W97NXi+APW/w==" }, "@ucap/ng-store-chat": { "version": "file:pack/ucap-ng-store-chat-0.0.3.tgz", @@ -2403,7 +2402,8 @@ }, "@ucap/ng-ui-authentication": { "version": "file:pack/ucap-ng-ui-authentication-0.0.14.tgz", - "integrity": "sha512-wejkhebthEUub9nGigu9/fENB7hwOHrYTDq4dPmitxKeb3o1RNdbjAzaEB0QlVmLF+/ReydWZqr2d4d8Dus+/g==" + "integrity": "sha512-wejkhebthEUub9nGigu9/fENB7hwOHrYTDq4dPmitxKeb3o1RNdbjAzaEB0QlVmLF+/ReydWZqr2d4d8Dus+/g==", + "dev": true }, "@ucap/ng-ui-organization": { "version": "file:pack/ucap-ng-ui-organization-0.0.2.tgz", diff --git a/package.json b/package.json index a6e3f18..9ae4ed0 100644 --- a/package.json +++ b/package.json @@ -165,7 +165,7 @@ "@ucap/ng-protocol-status": "file:pack/ucap-ng-protocol-status-0.0.1.tgz", "@ucap/ng-protocol-sync": "file:pack/ucap-ng-protocol-sync-0.0.1.tgz", "@ucap/ng-protocol-umg": "file:pack/ucap-ng-protocol-umg-0.0.1.tgz", - "@ucap/ng-store-authentication": "file:pack/ucap-ng-store-authentication-0.0.2.tgz", + "@ucap/ng-store-authentication": "file:pack/ucap-ng-store-authentication-0.0.3.tgz", "@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.3.tgz", "@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.3.tgz", "@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.3.tgz", diff --git a/projects/store-authentication/ng-package.json b/projects/store-authentication/ng-package.json index 8d45489..05193a5 100644 --- a/projects/store-authentication/ng-package.json +++ b/projects/store-authentication/ng-package.json @@ -8,6 +8,7 @@ "@ngrx/effects": "@ngrx/effects", "@ucap/pi": "@ucap/pi", "@ucap/protocol-authentication": "@ucap/protocol-authentication", + "@ucap/protocol-option": "@ucap/protocol-option", "@ucap/protocol-query": "@ucap/protocol-query", "@ucap/ng-pi": "@ucap/ng-pi", "@ucap/ng-protocol-authentication": "@ucap/ng-protocol-authentication", diff --git a/projects/store-authentication/package.json b/projects/store-authentication/package.json index fa2bf00..48663e5 100644 --- a/projects/store-authentication/package.json +++ b/projects/store-authentication/package.json @@ -1,6 +1,6 @@ { "name": "@ucap/ng-store-authentication", - "version": "0.0.2", + "version": "0.0.3", "publishConfig": { "registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/" }, diff --git a/projects/store-authentication/src/lib/store/authorization/actions.ts b/projects/store-authentication/src/lib/store/authorization/actions.ts index 4e773f8..8b71c07 100644 --- a/projects/store-authentication/src/lib/store/authorization/actions.ts +++ b/projects/store-authentication/src/lib/store/authorization/actions.ts @@ -1,6 +1,7 @@ import { createAction, props } from '@ngrx/store'; import { AuthRequest, AuthResponse } from '@ucap/protocol-query'; +import { RegViewRequest, RegViewResponse } from '@ucap/protocol-option'; /** * retrieve authorization information @@ -23,3 +24,25 @@ export const authFailure = createAction( '[ucap::authentication::authorization] auth Failure', props<{ error: any }>() ); + +/** + * retrieve authorization information + */ +export const regView = createAction( + '[ucap::authentication::authorization] regView', + props<{ req: RegViewRequest }>() +); +/** + * Success of regView request + */ +export const regViewSuccess = createAction( + '[ucap::authentication::authorization] regView Success', + props<{ res: RegViewResponse }>() +); +/** + * Failure of regView request + */ +export const regViewFailure = createAction( + '[ucap::authentication::authorization] regView Failure', + props<{ error: any }>() +); diff --git a/projects/store-authentication/src/lib/store/authorization/effects.ts b/projects/store-authentication/src/lib/store/authorization/effects.ts index 44d488a..e4de838 100644 --- a/projects/store-authentication/src/lib/store/authorization/effects.ts +++ b/projects/store-authentication/src/lib/store/authorization/effects.ts @@ -8,8 +8,17 @@ import { Actions, createEffect, ofType } from '@ngrx/effects'; import { AuthResponse } from '@ucap/protocol-query'; import { QueryProtocolService } from '@ucap/ng-protocol-query'; +import { OptionProtocolService } from '@ucap/ng-protocol-option'; -import { auth, authSuccess, authFailure } from './actions'; +import { + auth, + authSuccess, + authFailure, + regView, + regViewSuccess, + regViewFailure +} from './actions'; +import { RegViewResponse } from '@ucap/protocol-option'; @Injectable() export class Effects { @@ -30,8 +39,26 @@ export class Effects { ) ); + regView$ = createEffect(() => + this.actions$.pipe( + ofType(regView), + map(action => action.req), + exhaustMap(req => { + return this.optionProtocolService.regView(req).pipe( + map((res: RegViewResponse) => { + return regViewSuccess({ + res + }); + }), + catchError(error => of(regViewFailure({ error }))) + ); + }) + ) + ); + constructor( private actions$: Actions, - private queryProtocolService: QueryProtocolService + private queryProtocolService: QueryProtocolService, + private optionProtocolService: OptionProtocolService ) {} } diff --git a/projects/store-authentication/src/lib/store/authorization/state.ts b/projects/store-authentication/src/lib/store/authorization/state.ts index 91c7e92..7a2cadc 100644 --- a/projects/store-authentication/src/lib/store/authorization/state.ts +++ b/projects/store-authentication/src/lib/store/authorization/state.ts @@ -1,17 +1,27 @@ import { Selector, createSelector } from '@ngrx/store'; import { AuthResponse } from '@ucap/protocol-query'; +import { RegViewResponse } from '@ucap/protocol-option'; export interface State { - auth?: AuthResponse; + authResponse?: AuthResponse | null; + regViewResponse: RegViewResponse | null; } export const initialState: State = { - auth: null + authResponse: null, + regViewResponse: null }; export function selectors(selector: Selector) { return { - auth: createSelector(selector, (state: State) => state.auth) + authResponse: createSelector( + selector, + (state: State) => state.authResponse + ), + regViewResponse: createSelector( + selector, + (state: State) => state.regViewResponse + ) }; } diff --git a/projects/store-authentication/src/lib/store/login/effects.ts b/projects/store-authentication/src/lib/store/login/effects.ts index 3bc248b..3d1bbb0 100644 --- a/projects/store-authentication/src/lib/store/login/effects.ts +++ b/projects/store-authentication/src/lib/store/login/effects.ts @@ -1,64 +1,17 @@ import { of } from 'rxjs'; -import { catchError, exhaustMap, map, switchMap } from 'rxjs/operators'; +import { catchError, map, switchMap } from 'rxjs/operators'; import { Injectable } from '@angular/core'; import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Login2Response } from '@ucap/pi'; - import { PiService } from '@ucap/ng-pi'; import { AuthenticationProtocolService } from '@ucap/ng-protocol-authentication'; -import { - logout, - webLogin, - webLoginSuccess, - webLoginFailure, - logoutSuccess -} from './actions'; +import { logout, logoutSuccess } from './actions'; @Injectable() export class Effects { - webLogin$ = createEffect(() => - this.actions$.pipe( - ofType(webLogin), - map(action => action), - exhaustMap( - (params: { - loginId: string; - loginPw: string; - companyCode: string; - rememberMe: boolean; - autoLogin: boolean; - }) => - this.piService - .login2({ - loginId: params.loginId, - loginPw: params.loginPw, - companyCode: params.companyCode - }) - .pipe( - map((res: Login2Response) => { - if ('success' !== res.status.toLowerCase()) { - return webLoginFailure({ error: 'Failed' }); - } else { - return webLoginSuccess({ - loginId: params.loginId, - loginPw: params.loginPw, - companyCode: params.companyCode, - rememberMe: params.rememberMe, - autoLogin: params.autoLogin, - login2Response: res - }); - } - }), - catchError(error => of(webLoginFailure({ error }))) - ) - ) - ) - ); - logout$ = createEffect(() => { return this.actions$.pipe( ofType(logout),