diff options
Diffstat (limited to 'src/pages/Profile/Registration')
-rw-r--r-- | src/pages/Profile/Registration/Registration.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/pages/Profile/Registration/Registration.js b/src/pages/Profile/Registration/Registration.js index ce8384f..45c83bc 100644 --- a/src/pages/Profile/Registration/Registration.js +++ b/src/pages/Profile/Registration/Registration.js @@ -26,23 +26,25 @@ const Registration = ({ setUser }) => { }; const handleSubmit = () => { - post('users/', { username }) - .then(response => { - const user = response.data; - setUser(user); - if (isRememberMe) { - localStorage.setItem('userId', user.id); - } - }) - .catch(err => { - get('users/').then(response => { - const user = response.data.filter(user => user.username === username)[0]; + if (username !== '') { + post('users/', { username }) + .then(response => { + const user = response.data; setUser(user); if (isRememberMe) { localStorage.setItem('userId', user.id); } + }) + .catch(err => { + get('users/').then(response => { + const user = response.data.filter(user => user.username === username)[0]; + setUser(user); + if (isRememberMe) { + localStorage.setItem('userId', user.id); + } + }); }); - }); + } }; return ( |