Skip to content

Commit

Permalink
fix(ms-adal): Update createAuthenticationContext (#2705)
Browse files Browse the repository at this point in the history
* Update createAuthenticationContext

Update createAuthenticationContext to include validateAuthority flag since it is throwing Error: Fail to valid authority with errors: [50049].
Without the flag it is throwing Error: Fail to valid authority with errors: [50049].

* Update index.ts
  • Loading branch information
ratnakar24 authored and danielsogl committed Sep 15, 2018
1 parent 6a9a871 commit 890129b
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions src/@ionic-native/plugins/ms-adal/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Plugin, IonicNativePlugin, checkAvailability, InstanceProperty, CordovaInstance } from '@ionic-native/core';
import { Injectable } from '@angular/core';
import { checkAvailability, CordovaInstance, InstanceProperty, IonicNativePlugin, Plugin } from '@ionic-native/core';

export interface AuthenticationResult {

accessToken: string;
accesSTokenType: string;
expiresOn: Date;
Expand All @@ -18,7 +17,6 @@ export interface AuthenticationResult {
* @returns {String} The authorization header.
*/
createAuthorizationHeader(): string;

}

export interface TokenCache {
Expand Down Expand Up @@ -50,7 +48,6 @@ export interface UserInfo {
uniqueId: string;
}


/**
* @name MS ADAL
* @description
Expand Down Expand Up @@ -96,22 +93,28 @@ export interface UserInfo {
})
@Injectable()
export class MSAdal extends IonicNativePlugin {

createAuthenticationContext(authority: string, validateAuthority: boolean = true) {
createAuthenticationContext(
authority: string,
validateAuthority: boolean = true
) {
let authContext: any;
if (checkAvailability(MSAdal.getPluginRef(), null, MSAdal.getPluginName()) === true) {
authContext = new (MSAdal.getPlugin()).AuthenticationContext(authority);
if (
checkAvailability(MSAdal.getPluginRef(), null, MSAdal.getPluginName()) ===
true
) {
authContext = new (MSAdal.getPlugin()).AuthenticationContext(
authority,
validateAuthority
);
}
return new AuthenticationContext(authContext);
}

}

/**
* @hidden
*/
export class AuthenticationContext {

@InstanceProperty
authority: string;

Expand All @@ -138,7 +141,15 @@ export class AuthenticationContext {
@CordovaInstance({
otherPromise: true
})
acquireTokenAsync(resourceUrl: string, clientId: string, redirectUrl: string, userId?: string, extraQueryParameters?: any): Promise<AuthenticationResult> { return; }
acquireTokenAsync(
resourceUrl: string,
clientId: string,
redirectUrl: string,
userId?: string,
extraQueryParameters?: any
): Promise<AuthenticationResult> {
return;
}

/**
* Acquires token WITHOUT using interactive flow. It checks the cache to return existing result
Expand All @@ -153,6 +164,11 @@ export class AuthenticationContext {
@CordovaInstance({
otherPromise: true
})
acquireTokenSilentAsync(resourceUrl: string, clientId: string, userId?: string): Promise<AuthenticationResult> { return; }

acquireTokenSilentAsync(
resourceUrl: string,
clientId: string,
userId?: string
): Promise<AuthenticationResult> {
return;
}
}

0 comments on commit 890129b

Please sign in to comment.