File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed
Expand file tree Collapse file tree 3 files changed +51
-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+ if ( ! children ) {
8+ return (
9+ < a
10+ href = {
11+ process . env . REACT_APP_EASYAUTH_APP_URL +
12+ '/logout?target=' +
13+ btoa ( callback || window . location . href )
14+ }
15+ >
16+ < button
17+ onClick = { ( ) => {
18+ auth . removeUser ( ) ;
19+ } }
20+ >
21+ Sign Out
22+ </ button >
23+ </ a >
24+ ) ;
25+ }
26+ return (
27+ < a
28+ href = {
29+ process . env . REACT_APP_EASYAUTH_APP_URL +
30+ '/logout?target=' +
31+ btoa ( callback || window . location . href )
32+ }
33+ >
34+ < div
35+ onClick = { ( ) => {
36+ auth . removeUser ( ) ;
37+ } }
38+ >
39+ { children }
40+ </ div >
41+ </ a >
42+ ) ;
43+ } ;
44+
45+
46+ SignOutButton . propTypes = {
47+ callback : PropTypes . string ,
48+ children : PropTypes . node ,
49+ } ;
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