Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Router, ActivatedRoute } from '@angular/router';
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
import { AuthenticationService } from '../auth/auth.service';
import { DomSanitizer } from '@angular/platform-browser';
import { Sanitizer } from '@angular/core/src/security';
import { AppSettingsService } from './../shared/app-settings/app-settings.service';
import { CanDeactivateGuard } from '../shared/guards/can-deactivate-gaurd';
@Component({
selector: 'app-login-without-sso',
templateUrl: './login-without-sso.component.html',
styleUrls: ['./login-without-sso.component.scss']
})
export class LoginWithoutSSOComponent implements OnInit {
constructor(
private router: Router,
private activatedRoute: ActivatedRoute,
private authenticationService: AuthenticationService,
private fb: FormBuilder,
private sanitizer: DomSanitizer,
private appSettingsService: AppSettingsService,
private canDeactivateGuard: CanDeactivateGuard
) {}
errorMsg = '';
errorStatus = false;
safeUrl;
sso;
loginForm: FormGroup;
userInfo: any = {};
userName: string[] = [];
ngOnInit() {
this.getDropDown();
this.formInit();
}
formInit() {
this.loginForm = this.fb.group({
userName: [this.userName, Validators.required]
});
}
getDropDown() {
this.authenticationService.getDropDownInfo().subscribe(
data => {
this.userName = data;
},
error => {
console.log('no users', JSON.stringify(error));
}
);
}
accept() {
const user = this.loginForm.get('userName').value;
this.getUsrInfo(user);
this.canDeactivateGuard.setActive();
// this.authenticationService.getNtName(this.sso).subscribe();
}
getUsrInfo(userName) {
this.errorMsg = '';
this.errorStatus = false;
this.authenticationService.authenticateAndGetUserInfo(userName).subscribe(
data => {
this.userInfo = data;
this.redirect();
},
error => {
this.errorMsg = error['error'];
this.errorStatus = true;
}
);
}
redirect() {
if (this.userInfo.userRoles !== undefined) {
sessionStorage.setItem('jwt', this.userInfo.jwt);
// this.setSessionValues();
if (
this.userInfo.userRoles.some(
data => data === 'ARS_BASE_ATTACHMENT_USER'
)
) {
this.appSettingsService.setMenu();
this.router.navigate(['search275']);
} else if (this.userInfo.userRoles.some(data => data === 'ARS_ADMIN')) {
this.appSettingsService.setMenu();
this.router.navigate(['userAdmin']);
} else if (
this.userInfo.userRoles.some(data => data === 'EWV_BASE_USER')
) {
this.appSettingsService.setMenu();
this.router.navigate(['ewvSearch']);
} else if (this.userInfo.userRoles.some(data => data === 'EWV_ADMIN')) {
this.appSettingsService.setMenu();
this.router.navigate(['ewvAdmin']);
} else {
this.router.navigate(['/']);
}
}
}
setSessionValues() {
sessionStorage.setItem('jwt', this.userInfo.jwt);
}
}