File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @easyauth.io/easyauth-react" ,
3- "version" : " 1.0.2 " ,
3+ "version" : " 1.0.3 " ,
44 "description" : " React SDK for EasyAuth" ,
55 "main" : " dist/index.js" ,
66 "module" : " dist/index.es.js" ,
Original file line number Diff line number Diff line change 1+ import { useEasyauth } from '../../hooks/useEasyauth/useEasyauth.jsx' ;
2+ import PropTypes from 'prop-types' ;
3+ import React from 'react' ;
4+
5+ export const SignOutButton = ( { callback, children} ) => {
6+ const auth = useEasyauth ( ) ;
7+ const logoutLink =
8+ auth . settings . authority . substring ( 0 , auth . settings . authority . lastIndexOf ( '/' ) ) +
9+ '/logout?target=' +
10+ btoa ( callback || window . location . href ) ;
11+
12+ return (
13+ < div
14+ onClick = { ( ) => {
15+ auth . removeUser ( ) . then ( ( ) => ( window . location . href = logoutLink ) ) ;
16+ } }
17+ >
18+ { children ? children : < button style = { { cursor : 'pointer' } } > Sign Out</ button > }
19+ </ div >
20+ ) ;
21+ } ;
22+
23+
24+ SignOutButton . propTypes = {
25+ callback : PropTypes . string ,
26+ children : PropTypes . node ,
27+ } ;
Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ export * from './components/SignedInAndSignedOut/SignedOut.jsx';
66export * from './hooks/useUser/useUser.jsx' ;
77export * from './hooks/useStripe/useStripe.jsx' ;
88export * from './components/UserButton/UserButton.jsx' ;
9+ export * from './components/SignOutButton/SignOutButton.jsx' ;
You can’t perform that action at this time.
0 commit comments