@8base/web-auth0-auth-client
Advanced tools
Comparing version 0.10.2 to 0.10.3
@@ -219,7 +219,3 @@ "use strict"; | ||
_this.auth0.logout({ | ||
returnTo: _this.logoutRedirectUri | ||
}); | ||
case 2: | ||
case 1: | ||
case "end": | ||
@@ -257,2 +253,26 @@ return _context5.stop(); | ||
}))); | ||
(0, _defineProperty2.default)(this, "logout", | ||
/*#__PURE__*/ | ||
(0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee7() { | ||
var options, | ||
_args7 = arguments; | ||
return _regenerator.default.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {}; | ||
_this.auth0.logout((0, _objectSpread2.default)({ | ||
returnTo: _this.logoutRedirectUri | ||
}, options)); | ||
case 2: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
}))); | ||
this.workspaceId = workspaceId; | ||
@@ -259,0 +279,0 @@ this.logoutRedirectUri = logoutRedirectUri; |
{ | ||
"name": "@8base/web-auth0-auth-client", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"author": "8base", | ||
@@ -16,3 +16,3 @@ "repository": "https://github.com/8base/sdk", | ||
"dependencies": { | ||
"@8base/utils": "^0.10.2", | ||
"@8base/utils": "^0.10.3", | ||
"@babel/runtime": "^7.3.1", | ||
@@ -19,0 +19,0 @@ "auth0-js": "^9.9.1", |
@@ -39,2 +39,33 @@ # 8base web auth0 auth client | ||
const renderAuth = (auth) => { | ||
const authorize = async () => { | ||
const authData = await auth.authorize(); | ||
await auth.setAuthState({ | ||
token: authData.idToken, | ||
email: authData.email, | ||
}); | ||
}; | ||
const logout = async () => { | ||
await auth.purgeAuthState(); | ||
await auth.logout(); | ||
}; | ||
if (auth.isAuthorized) { | ||
return ( | ||
<div> | ||
<p>Hi ${auth.authState.email} !</p> | ||
<button type='button' onClick={ logout }>Logout</button> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div> | ||
<button type='button' onClick={ authorize }>Authorize with auth0<button/> | ||
</div> | ||
); | ||
}; | ||
... | ||
@@ -45,5 +76,3 @@ | ||
<AuthContext.Consumer> | ||
{ | ||
(auth: AuthContextProps) => (<div />) | ||
} | ||
{ renderAuth } | ||
</AuthContext.Consumer> | ||
@@ -50,0 +79,0 @@ ... |
Sorry, the diff of this file is not supported yet
18996
297
80
Updated@8base/utils@^0.10.3