teams-dev-samples icon indicating copy to clipboard operation
teams-dev-samples copied to clipboard

Add logout to tab-aad-msal2

Open RobPethick opened this issue 3 years ago • 1 comments

Sample

tab-aad-msal2

Author(s)

@BobGerman

Suggestion

Could we have a logout button on this app? I'm not quite sure how that flow should work within teams with msal2?

Cheers, Rob

Are you willing to help?

No

RobPethick avatar Jan 30 '22 20:01 RobPethick

Please using this method. logoutPopup or logoutRedirect up to your context

    logout() {
        const username = this.getUsername()
        const account = this.msalClient.getAccountByUsername(username)

        if (!account) {
            return false
        }

        try {
            this.msalClient.logoutPopup({
                account,
                postLogoutRedirectUri: postLogoutRedirectUri,
                mainWindowRedirectUri: postLogoutRedirectUri,
                popupWindowAttributes: {
                    popupSize: {
                        height: 535,
                        width: 600
                    },
                }
            });
        }
        catch (err) { console.log(err); }
    }

tiennguyen1293 avatar Jun 20 '22 08:06 tiennguyen1293