From 423d6c7a9319ebf3e5e6848a65fddb83dbcec27b Mon Sep 17 00:00:00 2001 From: warrenshiv Date: Sun, 3 Dec 2023 17:16:11 +0300 Subject: [PATCH] Error handling in the login page --- .../__pycache__/views.cpython-310.pyc | Bin 6471 -> 6443 bytes backend/artistsmgmt/views.py | 13 ++++++++++--- frontend/src/pages/homepage.js | 3 +-- frontend/src/pages/signup.js | 7 +++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/backend/artistsmgmt/__pycache__/views.cpython-310.pyc b/backend/artistsmgmt/__pycache__/views.cpython-310.pyc index 2a5568986c902b3b6eca4d710d9ab6bcc23a2ab8..0d119d6431d9410e1797518bcc85a5499e20a239 100644 GIT binary patch delta 859 zcmZ9K%WD%+6vpRHGU;s|Z8CZGku=8mm_BW~kh;<0q6jg4L9r1`wRhBn*vFl*MG;DE z7m9+)U5FbI5mdUdr2l{`H~j-7OSg9IPVhTzRdnEdIp6QzoOAD)`BK;}gqA`fzlO)R zS+~Ew2&LJ(oxU(zXSEZXp7P0YO~gfFOA`s3)lPw&21$w(ND9OP=>_Q!ogkeceIWfH zU7{PL+m68xz^6q9K6Bs);d?|DK6_Mk2;`W^f#eRW#>!`aj*C1{9%vY43XMHhZ()`i zZGEhsC%Eop)n03Aoe6zQD|6wQ(JXJXZA`jV$DLTL-0v5NB+;@x9H@*qZv$F5(sNMTFynppPDGkrmWRH=c$$GpN=>^(wN= z4{q(1Qz~MPvqx&qe8O!kTCG6)rj@x3BkLsp&B3#L*L|i&qHDO>c65~8Q5%t{QN+%d z>Sy#qC$*5hBqsT*1Y5lMd_$;)kR4(`cD=P%W?CBr0(iYo8E@gC$q8MjEl? zJc~Blr)^hO?Nxhh@)CVAcq6N+nH)_~(n%#XmDHgbDB{!lz0Jj4l1lFwG0nKiO~W+8 MZQ+R7WBL>P7iibN`Tzg` delta 809 zcmYL`&rcIU6vy{%x68EMt?l-wKxxH_EFdag{BeO3F(N<27-@(tI4fzbK&DF&h#CS1 z4KdNo!Gk9~NxWbhPbP9SUW^A12CqhM{tNmY#JI`4eed&TzVE%6*8?90>;>BnYxs(_ zx@SJMbM*2}Z;T!!Hv*+&!x~TV^rpts9@V-)j)P=)79`WpacI@~U-Vkl zTkfCpd@+uc+z6ki9$83dGZP4h)e#26G)4wRbul4#LhUjXS*J0%6=~2_`8)E(+6zOV zyf9nyZu;`8Ri+#AtX-zE5|TT%K~v4QHY2Jw-$%nli}K?ko~l51P8CocqkwL;hzjI$ z&2o%Ua2j+?*5ivzHRc*(T7HiY)4J?)w%9F&LO{EYYgQ46JMx#4p@-5;EYq~SpEyVJ zYVzO+l27F4#2{!qnJ^dC<`LCcTMh1AtcC@H1_I19gJ^?^+WwR)$w6~QZJ(99$&&e8 zxt`3Yt|SE9XIKpbhG~`|glZgb+$!It?qz)77b^ev?!ve`i-fV`|%$ {
{userData ? (
-

{userData.message}!

- {/* Display user-specific content */} +

Welcome, {userData.username}!

) : (

Loading...

diff --git a/frontend/src/pages/signup.js b/frontend/src/pages/signup.js index 90e82ab..f52a50d 100644 --- a/frontend/src/pages/signup.js +++ b/frontend/src/pages/signup.js @@ -57,8 +57,11 @@ const SignUpForm = () => { } } catch (error) { console.error("Error during signup:", error); - setErrorMessage("Error during signup. Please try again."); - setSuccessMessage(""); + if (error.response && error.response.status === 400) { + setErrorMessage("A user with that username already exists."); + } else { + setErrorMessage("Signup failed. Please try again."); + } } };