Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@easyauth.io/easyauth-react",
"version": "1.0.2",
"version": "1.0.3",
"description": "React SDK for EasyAuth",
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand Down
27 changes: 27 additions & 0 deletions src/components/SignOutButton/SignOutButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {useEasyauth} from '../../hooks/useEasyauth/useEasyauth.jsx';
import PropTypes from 'prop-types';
import React from 'react';

export const SignOutButton = ({callback, children}) => {
const auth = useEasyauth();
const logoutLink =
auth.settings.authority.substring(0, auth.settings.authority.lastIndexOf('/')) +
'/logout?target=' +
btoa(callback || window.location.href);

return (
<div
onClick={() => {
auth.removeUser().then(() => (window.location.href = logoutLink));
}}
>
{children ? children : <button style={{cursor: 'pointer'}}>Sign Out</button>}
</div>
);
};


SignOutButton.propTypes = {
callback: PropTypes.string,
children: PropTypes.node,
};
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './components/SignedInAndSignedOut/SignedOut.jsx';
export * from './hooks/useUser/useUser.jsx';
export * from './hooks/useStripe/useStripe.jsx';
export * from './components/UserButton/UserButton.jsx';
export * from './components/SignOutButton/SignOutButton.jsx';