@@ -8,6 +8,19 @@ type authChangeParam = (user?: User) => string | void;
8
8
export type Settings = Settings ;
9
9
export type User = User ;
10
10
11
+ const defaultSettings = {
12
+ autoconfirm : false ,
13
+ disable_signup : false ,
14
+ external : {
15
+ bitbucket : false ,
16
+ email : true ,
17
+ facebook : false ,
18
+ github : false ,
19
+ gitlab : false ,
20
+ google : false ,
21
+ } ,
22
+ } ;
23
+
11
24
export type ReactNetlifyIdentityAPI = {
12
25
user : User | undefined ;
13
26
/** not meant for normal use! you should mostly use one of the other exported methods to update the user instance */
@@ -47,7 +60,7 @@ export type ReactNetlifyIdentityAPI = {
47
60
provider : 'bitbucket' | 'github' | 'gitlab' | 'google' ,
48
61
token : string
49
62
) => string ;
50
- settings : ( ) => Promise < Settings > ;
63
+ settings : Settings ;
51
64
} ;
52
65
53
66
const [ _useIdentityCtx , _IdentityCtxProvider ] = createCtx <
@@ -74,10 +87,7 @@ export function IdentityContextProvider({
74
87
'. Please check the docs for proper usage or file an issue.'
75
88
) ;
76
89
}
77
- const identity = React . useMemo ( ( ) => useNetlifyIdentity ( url , onAuthChange ) , [
78
- url ,
79
- onAuthChange ,
80
- ] ) ;
90
+ const identity = useNetlifyIdentity ( url , onAuthChange ) ;
81
91
return (
82
92
< _IdentityCtxProvider value = { identity } > { children } </ _IdentityCtxProvider >
83
93
) ;
@@ -118,9 +128,11 @@ export function useNetlifyIdentity(
118
128
} ;
119
129
const acceptInviteExternalUrl = ( provider : Provider , token : string ) =>
120
130
goTrueInstance . acceptInviteExternalUrl ( provider , token ) ;
121
- const settings : ( ) => Promise < Settings > = goTrueInstance . settings . bind (
122
- goTrueInstance
123
- ) ;
131
+ const _settings = goTrueInstance . settings . bind ( goTrueInstance ) ;
132
+ const [ settings , setSettings ] = React . useState < Settings > ( defaultSettings ) ;
133
+ React . useEffect ( ( ) => {
134
+ _settings ( ) . then ( x => setSettings ( x ) ) ;
135
+ } , [ settings ] ) ;
124
136
125
137
/******* email auth */
126
138
const signupUser = ( email : string , password : string , data : Object ) =>
0 commit comments