backend/services/auth_service.py
CHANGED
@@ -54,6 +54,9 @@ def register_user(email: str, password: str) -> dict:
|
|
54 |
'message': 'Failed to register user'
|
55 |
}
|
56 |
except Exception as e:
|
|
|
|
|
|
|
57 |
# Check if it's a duplicate user error
|
58 |
error_str = str(e).lower()
|
59 |
if 'already registered' in error_str or 'already exists' in error_str:
|
@@ -66,15 +69,17 @@ def register_user(email: str, password: str) -> dict:
|
|
66 |
'success': False,
|
67 |
'message': 'Please enter a valid email address.'
|
68 |
}
|
69 |
-
|
|
|
70 |
return {
|
71 |
'success': False,
|
72 |
'message': 'Password does not meet requirements. Please use at least 8 characters.'
|
73 |
}
|
74 |
else:
|
|
|
75 |
return {
|
76 |
'success': False,
|
77 |
-
'message':
|
78 |
}
|
79 |
|
80 |
def login_user(email: str, password: str, remember_me: bool = False) -> dict:
|
|
|
54 |
'message': 'Failed to register user'
|
55 |
}
|
56 |
except Exception as e:
|
57 |
+
# Log the full error for debugging
|
58 |
+
current_app.logger.error(f"Registration error for email {email}: {str(e)}")
|
59 |
+
|
60 |
# Check if it's a duplicate user error
|
61 |
error_str = str(e).lower()
|
62 |
if 'already registered' in error_str or 'already exists' in error_str:
|
|
|
69 |
'success': False,
|
70 |
'message': 'Please enter a valid email address.'
|
71 |
}
|
72 |
+
# More specific check for Supabase password policy errors
|
73 |
+
elif 'password' in error_str and ('weak' in error_str or 'policy' in error_str or 'requirement' in error_str):
|
74 |
return {
|
75 |
'success': False,
|
76 |
'message': 'Password does not meet requirements. Please use at least 8 characters.'
|
77 |
}
|
78 |
else:
|
79 |
+
# For other errors, provide a more generic message to the user but log the details
|
80 |
return {
|
81 |
'success': False,
|
82 |
+
'message': 'Registration failed. Please check your information and try again.'
|
83 |
}
|
84 |
|
85 |
def login_user(email: str, password: str, remember_me: bool = False) -> dict:
|
frontend/src/store/reducers/sourcesSlice.js
CHANGED
@@ -77,7 +77,10 @@ const sourcesSlice = createSlice({
|
|
77 |
.addCase(addSource.fulfilled, (state, action) => {
|
78 |
state.loading = false;
|
79 |
// Add the new source to the list
|
80 |
-
|
|
|
|
|
|
|
81 |
})
|
82 |
.addCase(addSource.rejected, (state, action) => {
|
83 |
state.loading = false;
|
|
|
77 |
.addCase(addSource.fulfilled, (state, action) => {
|
78 |
state.loading = false;
|
79 |
// Add the new source to the list
|
80 |
+
// The payload should contain the full source object, not just a success message
|
81 |
+
if (action.payload && action.payload.source) {
|
82 |
+
state.items = [...state.items, action.payload.source];
|
83 |
+
}
|
84 |
})
|
85 |
.addCase(addSource.rejected, (state, action) => {
|
86 |
state.loading = false;
|