import { AbpSessionService } from 'abp-ng2-module' ; import { Component , Injector , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { AppComponentBase } from '@shared/common/app-component-base' ; import { SessionServiceProxy , UpdateUserSignInTokenOutput } from '@shared/service-proxies/service-proxies' ; import { UrlHelper } from '@shared/helpers/UrlHelper' ; import { ExternalLoginProvider , LoginService } from './login.service' ; @ Component ( { templateUrl : './login.component.html' , styleUrls : [ './login.component.less' ] , } ) export class LoginComponent extends AppComponentBase implements OnInit { submitting = false ; isMultiTenancyEnabled : boolean = this . multiTenancy . isEnabled ; constructor ( injector , public loginService , private _router , private _sessionService , private _sessionAppService ) { super ( injector ) ; } get multiTenancySideIsTeanant ( ) : boolean { return this . _sessionService . tenantId > 0 ; } get isTenantSelfRegistrationAllowed ( ) : boolean { return this . setting . getBoolean ( 'App.TenantManagement.AllowSelfRegistration' ) ; } get isSelfRegistrationAllowed ( ) : boolean { if ( ! this . _sessionService . tenantId ) { return false ; } return this . setting . getBoolean ( 'App.UserManagement.AllowSelfRegistration' ) ; } ngOnInit ( ) { this . loginService . init ( ) ; if ( this . _sessionService . userId > 0 && UrlHelper . getReturnUrl ( ) && UrlHelper . getSingleSignIn ( ) ) { this . _sessionAppService . updateUserSignInToken ( ) . subscribe ( ( result ) => { const initialReturnUrl = UrlHelper . getReturnUrl ( ) ; const returnUrl = initialReturnUrl + ( initialReturnUrl . indexOf ( '?' ) >= 0 ? '&' : '?' ) + 'accessToken=' + result . signInToken + '&userId=' + result . encodedUserId + '&tenantId=' + result . encodedTenantId ; location . href = returnUrl ; } ) ; } let state = UrlHelper . getQueryParametersUsingHash ( ) . state ; if ( state && state . indexOf ( 'openIdConnect' ) >= 0 ) { this . loginService . openIdConnectLoginCallback ( { } ) ; } } login ( ) { this . submitting = true ; this . loginService . authenticate ( ( ) => this . submitting = false ) ; } externalLogin ( provider ) { this . loginService . externalAuthenticate ( provider ) ; } }