@@ -19,7 +19,25 @@ class Auth {
19
19
. post ( `${ authUrl } /signup` , { email, password } )
20
20
. set ( 'accept' , 'json' )
21
21
. set ( 'apikey' , this . supabaseKey )
22
- return this . login ( email , password )
22
+
23
+ if ( response . status === 200 && response [ 'body' ] [ 'user' ] [ 'confirmed_at' ] ) {
24
+ this . accessToken = response . body [ 'access_token' ]
25
+ this . refreshToken = response . body [ 'refresh_token' ]
26
+ this . currentUser = response . body [ 'user' ]
27
+ let tokenExpirySeconds = response . body [ 'expires_in' ]
28
+ if ( this . autoRefreshToken && tokenExpirySeconds )
29
+ setTimeout ( this . callRefreshToken , ( tokenExpirySeconds - 60 ) * 1000 )
30
+ if ( this . persistSession ) {
31
+ const timeNow = Math . round ( Date . now ( ) / 1000 )
32
+ this . saveSession (
33
+ this . accessToken ,
34
+ this . refreshToken ,
35
+ timeNow + tokenExpirySeconds ,
36
+ this . currentUser
37
+ )
38
+ }
39
+ }
40
+ return response
23
41
}
24
42
25
43
this . login = async ( email , password ) => {
@@ -32,6 +50,7 @@ class Auth {
32
50
if ( response . status === 200 ) {
33
51
this . accessToken = response . body [ 'access_token' ]
34
52
this . refreshToken = response . body [ 'refresh_token' ]
53
+ this . currentUser = response . body [ 'user' ]
35
54
let tokenExpirySeconds = response . body [ 'expires_in' ]
36
55
if ( this . autoRefreshToken && tokenExpirySeconds )
37
56
setTimeout ( this . callRefreshToken , ( tokenExpirySeconds - 60 ) * 1000 )
0 commit comments