@cimpress/simple-auth-wrapper
Advanced tools
Comparing version 6.1.0 to 6.2.0
@@ -309,3 +309,3 @@ 'use strict'; | ||
this.logout = function (nextUri) { | ||
this.logout = function (nextUri, logoutOfFederated) { | ||
// logout locally | ||
@@ -315,5 +315,12 @@ _this.removeToken(); | ||
var returnTo = nextUri ? { returnTo: window.location.origin + nextUri } : {}; | ||
_this.auth0.logout(_extends({ | ||
client_id: _this.clientID | ||
}, returnTo)); | ||
if (logoutOfFederated) { | ||
_this.auth0.logout(_extends({ | ||
client_id: _this.clientID, | ||
federated: true | ||
}, returnTo)); | ||
} else { | ||
_this.auth0.logout(_extends({ | ||
client_id: _this.clientID | ||
}, returnTo)); | ||
} | ||
}; | ||
@@ -320,0 +327,0 @@ }; |
{ | ||
"name": "@cimpress/simple-auth-wrapper", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"description": "A simple utility class to wrap basic Auth0 functionality", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -47,3 +47,4 @@ # MEX Simple Auth Wrapper v. 3.0 | ||
`logout()` Logs a user out and removes their token and profile from local storage. Also logs them out from the identity provider. | ||
`logout(nextUrl, logoutOfFederated)` Logs a user out and removes their token and profile from local storage. Will open URL provided in nextURL. | ||
If the optional logoutOfFederated is provided and is true, will also log user out from the identity provider. Note: this is not a common use case and most apps will not need to provide this parameter. For more information reference https://auth0.com/docs/logout | ||
@@ -50,0 +51,0 @@ #### Subscribing to Events |
@@ -240,13 +240,21 @@ import Auth0 from 'auth0-js'; | ||
// can result in redirect | ||
logout = (nextUri) => { | ||
logout = (nextUri, logoutOfFederated) => { | ||
// logout locally | ||
this.removeToken(); | ||
// also log out with auth0 | ||
const returnTo = nextUri ? {returnTo: window.location.origin + nextUri} : {} | ||
this.auth0.logout({ | ||
client_id: this.clientID, | ||
...returnTo | ||
}); | ||
const returnTo = nextUri ? {returnTo: window.location.origin + nextUri} : {}; | ||
if (logoutOfFederated) { | ||
this.auth0.logout({ | ||
client_id: this.clientID, | ||
federated: true, | ||
...returnTo | ||
}); | ||
} else { | ||
this.auth0.logout({ | ||
client_id: this.clientID, | ||
...returnTo | ||
}); | ||
} | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
264463
1150
106