File tree Expand file tree Collapse file tree 1 file changed +11
-33
lines changed
src/components/SignOutButton Expand file tree Collapse file tree 1 file changed +11
-33
lines changed Original file line number Diff line number Diff line change @@ -4,41 +4,19 @@ import React from 'react';
44
55export const SignOutButton = ( { callback, children} ) => {
66 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- }
7+ const logoutLink =
8+ auth . settings . authority . substring ( 0 , auth . settings . authority . lastIndexOf ( '/' ) ) +
9+ '/logout?target=' +
10+ btoa ( callback || window . location . href ) ;
11+
2612 return (
27- < a
28- href = {
29- process . env . REACT_APP_EASYAUTH_APP_URL +
30- '/logout?target=' +
31- btoa ( callback || window . location . href )
32- }
13+ < div
14+ onClick = { ( ) => {
15+ auth . removeUser ( ) . then ( ( ) => ( window . location . href = logoutLink ) ) ;
16+ } }
3317 >
34- < div
35- onClick = { ( ) => {
36- auth . removeUser ( ) ;
37- } }
38- >
39- { children }
40- </ div >
41- </ a >
18+ { children ? children : < button style = { { cursor : 'pointer' } } > Sign Out</ button > }
19+ </ div >
4220 ) ;
4321} ;
4422
You can’t perform that action at this time.
0 commit comments