{ "version": 3, "sources": ["angular:jit:template:file:src/app/login/components/login/login.component.html", "angular:jit:style:file:src/app/login/components/login/login.component.scss", "src/app/b2c-config.ts", "src/app/login/components/login/login.component.ts"], "sourcesContent": ["
\n \n
\n", "/* src/app/login/components/login/login.component.scss */\n/*# sourceMappingURL=login.component-KGAAR7AU.css.map */\n", "import { environment } from 'src/environments/environment';\n\n/**\n * Enter here the user flows and custom policies for your B2C application\n * To learn more about user flows, visit: https://docs.microsoft.com/en-us/azure/active-directory-b2c/user-flow-overview\n * To learn more about custom policies, visit: https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-overview\n */\nexport const b2cPolicies = {\n names: {\n signUpSignIn: environment.b2cNameSignUpSignIn,\n editProfile: environment.b2cNameEditProfile,\n resetPassword: environment.b2cAuthorityForgotPassword,\n },\n authorities: {\n signUpSignIn: {\n authority: environment.b2cAuthoritySignUpSignIn,\n },\n editProfile: {\n authority: environment.b2cAuthorityEditProfile,\n },\n resetPassword: {\n authority: environment.b2cAuthorityForgotPassword,\n },\n },\n authorityDomain: environment.b2cAuthorityDomain,\n};\n\n/**\n * Enter here the coordinates of your web API and scopes for access token request\n * The current application coordinates were pre-registered in a B2C tenant.\n */\nexport const apiConfig: { scopes: string[]; uri: string } = {\n scopes: environment.b2cScopes,\n uri: environment.b2cApiUrl,\n};\n", "import { Component, Inject, OnDestroy, OnInit } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { MSAL_GUARD_CONFIG, MsalGuardConfiguration, MsalService, MsalBroadcastService } from '@azure/msal-angular';\nimport {\n InteractionStatus,\n EventMessage,\n EventType,\n AuthenticationResult,\n InteractionType,\n PopupRequest,\n RedirectRequest,\n AuthError,\n} from '@azure/msal-browser';\nimport { Store } from '@ngrx/store';\nimport { RootState } from '@store/index';\nimport { Subject, Subscription } from 'rxjs';\nimport { filter, takeUntil } from 'rxjs/operators';\nimport { b2cPolicies } from './../../../b2c-config';\n\nimport * as UserActions from '@store/user/user.actions';\n\n@Component({\n selector: 'app-login',\n templateUrl: './login.component.html',\n styleUrls: ['./login.component.scss'],\n})\nexport class LoginComponent implements OnInit, OnDestroy {\n title = 'airia';\n loginDisplay = false;\n\n private readonly destroying$ = new Subject();\n loginSubscription: Subscription;\n\n get authenticated(): boolean {\n return this.authService.instance.getActiveAccount() ? true : false;\n }\n\n constructor(\n @Inject(MSAL_GUARD_CONFIG) private msalGuardConfig: MsalGuardConfiguration,\n private authService: MsalService,\n private msalBroadcastService: MsalBroadcastService,\n private router: Router,\n private store: Store\n ) {\n this.loginSubscription = this.msalBroadcastService.msalSubject$\n .pipe(\n filter(\n (msg: EventMessage) => msg.eventType === EventType.LOGIN_SUCCESS || msg.eventType === EventType.ACQUIRE_TOKEN_SUCCESS\n )\n )\n .subscribe((result: EventMessage) => {\n const payload = result.payload as AuthenticationResult;\n this.authService.instance.setActiveAccount(payload.account);\n console.log('redirecting to map');\n this.router.navigate(['/map']);\n });\n\n this.msalBroadcastService.msalSubject$\n .pipe(filter((msg: EventMessage) => msg.eventType === EventType.LOGIN_SUCCESS))\n .subscribe((result: EventMessage) => {\n console.log('Successfully logged in.');\n });\n }\n checkLoggedIn(): void {\n this.store.dispatch(UserActions.getSelf());\n }\n\n ngOnInit(): void {\n this.getLoginStatus();\n }\n\n async getLoginStatus(): Promise {\n await this.msalBroadcastService.msalSubject$\n .pipe(\n filter(\n (msg: EventMessage) => msg.eventType !== EventType.LOGIN_SUCCESS && msg.eventType !== EventType.ACQUIRE_TOKEN_SUCCESS\n ),\n takeUntil(this.destroying$)\n )\n .subscribe((result: EventMessage) => {\n this.loginDisplay = false;\n const error: AuthError = result.error as AuthError;\n if (error?.errorCode === 'no_tokens_found') {\n this.authService.logoutRedirect().subscribe();\n } else if (error?.errorMessage.indexOf('AADB2C90118') > -1) {\n const resetPasswordFlowRequest = {\n scopes: ['openid', 'profile'],\n authority: b2cPolicies.authorities.resetPassword.authority,\n };\n this.authService.loginRedirect(resetPasswordFlowRequest);\n } else if (error?.errorMessage.indexOf('AADB2C90091') > -1) {\n // Return to Login screen\n this.authService.loginRedirect();\n } else if (error) {\n console.log('error unaccounted for', result);\n }\n });\n\n this.msalBroadcastService.inProgress$\n .pipe(\n filter((status: InteractionStatus) => status === InteractionStatus.None),\n takeUntil(this.destroying$)\n )\n .subscribe(async (result) => {\n if (!this.authenticated) {\n console.log('Not authenticated, redirect to login');\n this.authService.loginRedirect();\n }\n });\n }\n\n setLoginDisplay(): void {\n this.loginDisplay = this.authService.instance.getAllAccounts().length === 0;\n }\n\n checkAndSetActiveAccount(): void {\n /**\n * If no active account set but there are accounts signed in, sets first account to active account\n * To use active account set here, subscribe to inProgress$ first in your component\n * Note: Basic usage demonstrated. Your app may require more complicated account selection logic\n */\n const activeAccount = this.authService.instance.getActiveAccount();\n\n if (!activeAccount && this.authService.instance.getAllAccounts().length > 0) {\n const accounts = this.authService.instance.getAllAccounts();\n this.authService.instance.setActiveAccount(accounts[0]);\n }\n }\n\n login(userFlowRequest?: RedirectRequest | PopupRequest): void {\n if (this.msalGuardConfig.interactionType === InteractionType.Popup) {\n if (this.msalGuardConfig.authRequest) {\n this.authService\n .loginPopup({\n ...this.msalGuardConfig.authRequest,\n ...userFlowRequest,\n } as PopupRequest)\n .subscribe((response: AuthenticationResult) => {\n this.authService.instance.setActiveAccount(response.account);\n });\n } else {\n this.authService.loginPopup(userFlowRequest).subscribe((response: AuthenticationResult) => {\n this.authService.instance.setActiveAccount(response.account);\n });\n }\n } else {\n if (this.msalGuardConfig.authRequest) {\n this.authService.loginRedirect({\n ...this.msalGuardConfig.authRequest,\n ...userFlowRequest,\n } as RedirectRequest);\n } else {\n this.authService.loginRedirect(userFlowRequest);\n }\n }\n }\n\n logout(): void {\n if (this.msalGuardConfig.interactionType === InteractionType.Popup) {\n this.authService.logoutPopup({\n mainWindowRedirectUri: '/',\n });\n } else {\n this.authService.logoutRedirect();\n }\n }\n\n editProfile(): void {\n const editProfileFlowRequest = {\n scopes: ['openid'],\n authority: b2cPolicies.authorities.editProfile.authority,\n };\n\n this.login(editProfileFlowRequest);\n }\n\n ngOnDestroy(): void {\n this.destroying$.next(undefined);\n this.destroying$.complete();\n this.loginSubscription?.unsubscribe();\n }\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA,IAAAA,2BAAA;;;ACOO,IAAM,cAAc;EACvB,OAAO;IACH,cAAc,YAAY;IAC1B,aAAa,YAAY;IACzB,eAAe,YAAY;;EAE/B,aAAa;IACT,cAAc;MACV,WAAW,YAAY;;IAE3B,aAAa;MACT,WAAW,YAAY;;IAE3B,eAAe;MACX,WAAW,YAAY;;;EAG/B,iBAAiB,YAAY;;AAO1B,IAAM,YAA+C;EACxD,QAAQ,YAAY;EACpB,KAAK,YAAY;;;;ACPd,IAAM,iBAAN,MAAMC,gBAAc;EAOvB,IAAI,gBAAa;AACb,WAAO,KAAK,YAAY,SAAS,iBAAgB,IAAK,OAAO;EACjE;EAEA,YACuC,iBAC3B,aACA,sBACA,QACA,OAAuB;AAJI,SAAA,kBAAA;AAC3B,SAAA,cAAA;AACA,SAAA,uBAAA;AACA,SAAA,SAAA;AACA,SAAA,QAAA;AAfZ,SAAA,QAAQ;AACR,SAAA,eAAe;AAEE,SAAA,cAAc,IAAI,QAAO;AActC,SAAK,oBAAoB,KAAK,qBAAqB,aAC9C,KACG,OACI,CAAC,QAAsB,IAAI,cAAc,UAAU,iBAAiB,IAAI,cAAc,UAAU,qBAAqB,CACxH,EAEJ,UAAU,CAAC,WAAwB;AAChC,YAAM,UAAU,OAAO;AACvB,WAAK,YAAY,SAAS,iBAAiB,QAAQ,OAAO;AAC1D,cAAQ,IAAI,oBAAoB;AAChC,WAAK,OAAO,SAAS,CAAC,MAAM,CAAC;IACjC,CAAC;AAEL,SAAK,qBAAqB,aACrB,KAAK,OAAO,CAAC,QAAsB,IAAI,cAAc,UAAU,aAAa,CAAC,EAC7E,UAAU,CAAC,WAAwB;AAChC,cAAQ,IAAI,yBAAyB;IACzC,CAAC;EAC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