File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -31,17 +31,24 @@ export class AuthService{
31
31
async login ( { email, password} ) {
32
32
// eslint-disable-next-line no-useless-catch
33
33
try {
34
- await this . account . createEmailPasswordSession ( email , password ) ;
34
+ console . log ( "Creating email/password session for:" , email ) ;
35
+ const session = await this . account . createEmailPasswordSession ( email , password ) ;
36
+ console . log ( "Session created:" , session ) ;
37
+ return session ;
35
38
} catch ( error ) {
36
39
throw error
37
40
}
38
41
}
39
42
40
43
async getCurrentUser ( ) {
41
44
try {
42
- return await this . account . get ( ) ;
45
+ console . log ( "Calling getCurrentUser" ) ;
46
+ const user = await this . account . get ( ) ;
47
+ console . log ( "getCurrentUser result:" , user ) ;
48
+ return user ;
43
49
} catch ( error ) {
44
50
console . log ( "Appwrite service :: getCurrentUser :: error" , error ) ;
51
+ throw error ;
45
52
}
46
53
// return null;//in case the account get method fails to return an error;
47
54
}
Original file line number Diff line number Diff line change @@ -16,11 +16,13 @@ function Login() {
16
16
const login = async ( data ) => {
17
17
setError ( "" ) //clear all error on submission start
18
18
try {
19
+ console . log ( "Attempting to log in with data:" , data ) ;
19
20
const session = await authService . login ( data )
20
21
console . log ( "session done" )
21
22
if ( session ) {
23
+ console . log ( "Fetching current user" ) ;
22
24
const userData = await authService . getCurrentUser ( )
23
- console . log ( userData )
25
+ console . log ( "Inside session" , userData )
24
26
if ( userData ) {
25
27
dispatch ( authLogin ( userData ) ) ;
26
28
}
@@ -35,7 +37,7 @@ function Login() {
35
37
navigate ( '/' ) ; // Navigate to home page if user is logged in
36
38
}
37
39
} , [ userData , navigate ] ) ;
38
-
40
+
39
41
return (
40
42
< div
41
43
className = 'flex items-center justify-center w-full pt-5 pb-5'
You can’t perform that action at this time.
0 commit comments