Skip to content

Commit

Permalink
Added redirect by return URL for AAD and AAD B2C flows. (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov authored Jun 11, 2020
1 parent 7c905f6 commit 8d9113f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/services/aadService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class AadService {

const response = await this.httpClient.send(request);
const sasTokenHeader = response.headers.find(x => x.name.toLowerCase() === "ocp-apim-sas-token");

const returnUrl = this.routeHelper.getQueryParameter("returnUrl");

if (!sasTokenHeader) { // User not registered with APIM.
const jwtToken = Utils.parseJwt(idToken);
const firstName = jwtToken.given_name;
Expand All @@ -49,7 +50,7 @@ export class AadService {

if (firstName && lastName && email) {
await this.usersService.createUserWithOAuth(provider, idToken, firstName, lastName, email);
await this.router.navigateTo(Constants.pageUrlHome);
await this.router.navigateTo(returnUrl || Constants.pageUrlHome);
}
else {
const signupUrl = this.routeHelper.getIdTokenReferenceUrl(provider, idToken);
Expand All @@ -68,7 +69,7 @@ export class AadService {

const sasToken = matches[1];
await this.authenticator.setAccessToken(`SharedAccessSignature ${sasToken}`);
await this.router.navigateTo(Constants.pageUrlHome);
await this.router.navigateTo(returnUrl || Constants.pageUrlHome);
}

/**
Expand Down

0 comments on commit 8d9113f

Please sign in to comment.