import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, Resolve } from '@angular/router'; import { AuthService } from '@core/services/auth.service'; import { environment } from '@environment'; @Injectable({ providedIn: 'root' }) export class BlackbaudSsoRedirectResolver implements Resolve { constructor ( private authService: AuthService ) { } async resolve (_route: ActivatedRouteSnapshot) { // if trying to get onto the platform tools from localhost if (environment.isLocalhost) { // redirect to QA and indicate that we are trying to get back to localhost const locationBase = environment.locationBase === 'localhost' ? 'yourcausegrantsqa.com' : environment.locationBase; location.href = `https://www.${locationBase}/platform/auth/signin?platformHostRename=${encodeURIComponent('localhost:51851')}`; return; } if (environment.locationBase === 'dev-grantsconnect-ui.azurewebsites.net') { location.href = `https://www.yourcausegrantsqa.com/platform/auth/signin?platformHostRename=${encodeURIComponent('dev-grantsconnect-ui.azurewebsites.net')}`; return; } const potentialRedirect = _route.queryParamMap.get('platformHostRename'); // check for redirect if (potentialRedirect) { // remember this in order to perform redirect after SSO redirect sessionStorage.setItem('platformHostRename', potentialRedirect); } const response = await this.authService.getBlackbaudLoginRoute(); location.href = response.signInUrl; } }