Commit 1cef11c5 by GD-A-150752

S53525056 # Client - Incoming Issues #SMS Issues

parent 4ffb5a38
...@@ -124,12 +124,12 @@ export const routes: Routes = [ ...@@ -124,12 +124,12 @@ export const routes: Routes = [
] ]
}, },
{ {
path: 'applicant/:job', path: 'applicant/:job/job/:jobId',
component: ApplicantPortalLayoutComponent, component: ApplicantPortalLayoutComponent,
canActivate: [AuthGuard], canActivate: [AuthGuard],
data: { data: {
privs: ['TL_AccessApplicantPortal'], privs: ['TL_AccessApplicantPortal'],
redirectPage: 'ApplicantPortal-ApplyJob.htm?cms.rm=SignIn&JobID=:job' redirectPage: 'ApplicantPortal-ApplyJob.htm?cms.rm=SignIn&JobID=:jobId'
}, },
children: [ children: [
{ {
......
...@@ -9,7 +9,6 @@ import { ApiService } from '../services/api.service'; ...@@ -9,7 +9,6 @@ import { ApiService } from '../services/api.service';
import { UserService } from '../services/user.service'; import { UserService } from '../services/user.service';
import { UtilsService } from '../services/utils.service'; import { UtilsService } from '../services/utils.service';
@Injectable() @Injectable()
export class AuthGuard implements CanActivate { export class AuthGuard implements CanActivate {
constructor( constructor(
...@@ -24,41 +23,45 @@ export class AuthGuard implements CanActivate { ...@@ -24,41 +23,45 @@ export class AuthGuard implements CanActivate {
canActivate( canActivate(
route: ActivatedRouteSnapshot, route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> { state: RouterStateSnapshot): Observable<boolean> {
let params = { const params = {
environment: environment.envName, environment: environment.envName,
queryType: "All" queryType: 'All'
} };
return this.apiService.post(`svc/EnvironmentInformation`, params).map( return this.apiService.post('svc/EnvironmentInformation', params)
(data) => { .map(data => {
if (this.utilServices.isSuccessfulResponse(data)) { if (this.utilServices.isSuccessfulResponse(data)) {
let redirectPage = route.data["redirectPage"] || "editor/"; let redirectPage = route.data.redirectPage || 'editor/';
this.userService.setDetailsFromData(data); this.userService.setDetailsFromData(data);
if (data.UserName == "noprivauthtoken") { if (data.UserName === 'noprivauthtoken') {
const url = window.location.href; const url = window.location.href;
const matches = url.match(/applicant\/(\d+)\/message-engine/); const matches = url.match(/job\/(\d+)\/message-engine/);
if (matches[1]) { if (matches[1]) {
redirectPage = redirectPage.replace(':job', matches[1]); redirectPage = redirectPage.replace(':jobId', matches[1]);
window.location.href = (environment.baseUrl + redirectPage);
return false;
} }
window.location.href = (environment.baseUrl + redirectPage + "?url=" + encodeURIComponent(url)); window.location.href = (`${environment.baseUrl + redirectPage}?url=${encodeURIComponent(url)}`);
return false; return false;
} else { } else {
let privs = route.data["privs"] as Array<string>; const privs = route.data.privs as Array<string>;
if (privs) { if (privs) {
if (!this.userService.hasPrivilegeFromMultiple(privs)) { if (!this.userService.hasPrivilegeFromMultiple(privs)) {
this.router.navigate(['access-denied']); this.router.navigate(['access-denied']);
} }
} }
//localStorage.setItem('userid', data.UserID); // localStorage.setItem('userid', data.UserID);
return true; return true;
} }
} }
} }
) )
.catch( .catch(() => of(false)
(err) => of(false)
); );
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment