Commit 1cef11c5 by GD-A-150752

S53525056 # Client - Incoming Issues #SMS Issues

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