From 0977472a768366004fb0dec595c22964c22f6889 Mon Sep 17 00:00:00 2001 From: Sunil Shetye Date: Wed, 9 Jul 2025 17:35:39 +0530 Subject: add 201 and 204 to success codes --- blocks/blocks/settings.py | 1 + blocks/eda-frontend/src/redux/authSlice.js | 10 +++++----- blocks/init.sh | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/blocks/blocks/settings.py b/blocks/blocks/settings.py index 8f9d6a87..40dc5a11 100644 --- a/blocks/blocks/settings.py +++ b/blocks/blocks/settings.py @@ -141,6 +141,7 @@ EMAIL_PORT = int(os.environ.get('EMAIL_PORT', '587')) EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', '') EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', '') EMAIL_USE_TLS = os.environ.get('EMAIL_USE_TLS', 'true').lower() == 'true' +DEFAULT_FROM_EMAIL = os.environ.get('FROM_EMAIL', 'webmaster@localhost') if EMAIL_HOST: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' diff --git a/blocks/eda-frontend/src/redux/authSlice.js b/blocks/eda-frontend/src/redux/authSlice.js index ee5705c1..bb8e9644 100644 --- a/blocks/eda-frontend/src/redux/authSlice.js +++ b/blocks/eda-frontend/src/redux/authSlice.js @@ -32,7 +32,7 @@ export const loadUser = createAsyncThunk( try { const res = await api.get('auth/users/me/', config) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { return res.data } return rejectWithValue(res.data || 'Failed to load user') @@ -69,7 +69,7 @@ export const login = createAsyncThunk( email, password }) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { localStorage.setItem(tokenKey, res.data.auth_token) if (toUrl === '') { dispatch(loadUser()) @@ -117,7 +117,7 @@ export const signUp = createAsyncThunk( password, re_password: reenterPassword }) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { return 'Successfully Signed Up! A verification link has been sent to your email account.' } @@ -165,7 +165,7 @@ export const googleLogin = createAsyncThunk( async (host, { rejectWithValue }) => { try { const res = await api.get(`auth/o/google-oauth2/?redirect_uri=${host}/api/auth/google-callback`) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { // Open google login page window.open(res.data.authorization_url, '_self') return res.data.authorization_url @@ -185,7 +185,7 @@ export const githubLogin = createAsyncThunk( async (host, { rejectWithValue }) => { try { const res = await api.get(`auth/o/github/?redirect_uri=${host}/api/auth/github-callback`) - if (res.status === 200) { + if ([200, 201, 204].includes(res.status)) { // Open GitHub login page window.open(res.data.authorization_url, '_self') return res.data.authorization_url diff --git a/blocks/init.sh b/blocks/init.sh index ef98711c..16215a00 100755 --- a/blocks/init.sh +++ b/blocks/init.sh @@ -7,8 +7,8 @@ PASSWORD='' rm -f xcosblocks.sqlite3 -./manage.py migrate -v0 -./manage.py loaddata xcosblocks +python manage.py migrate -v0 +python manage.py loaddata -v0 saveAPI xcosblocks echo "from authAPI.models import User; User.objects.create_superuser('$EMAIL', '$EMAIL', '$PASSWORD')" | - ./manage.py shell + python manage.py shell -- cgit