all files / adal-ts2/src/ aad.logout.url.builder.ts

100% Statements 14/14
50% Branches 1/2
100% Functions 4/4
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  1× 1×   12×   1× 3× 3× 3×   1× 2× 2× 2×   1×   1× 1×              
import { GuidGenerator } from './guid.generator';
import { AadUrlConfig } from './aad.url.config';
export class AadLogoutUrlBuilder {
 
    private tenant: string;
    private postLogoutRedirectUri: string;
    public static MicrosoftLoginUrl: string = 'https://login.microsoftonline.com/';
 
    constructor() {
        this.postLogoutRedirectUri = window.location.href;
    }
 
    public with(tenant: string, postLogoutRedirectUri?: string): AadLogoutUrlBuilder {
        this.tenant = tenant;
        this.postLogoutRedirectUri = postLogoutRedirectUri || this.postLogoutRedirectUri;
        return this;
    }
 
    public build() {
 
        let urlNavigate = AadLogoutUrlBuilder.MicrosoftLoginUrl + this.tenant + '/oauth2/logout?';
 
        urlNavigate = urlNavigate + 'post_logout_redirect_uri=' + encodeURIComponent(this.postLogoutRedirectUri);
 
        return urlNavigate;
    }
}