From f88256eb74c2b24ba8a5995c58c7156db8710209 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 16 Feb 2020 07:39:36 +0000 Subject: [PATCH] Complain if they log in with email --- webclient/src/LoginSignup.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/webclient/src/LoginSignup.js b/webclient/src/LoginSignup.js index 309a6e7..473d63a 100644 --- a/webclient/src/LoginSignup.js +++ b/webclient/src/LoginSignup.js @@ -13,20 +13,24 @@ export function LoginForm(props) { const handleChange = (e) => handleValues(e, e.currentTarget); const handleSubmit = (e) => { - if (loading) return; - setLoading(true); - const data = { ...input, username: input.username.toLowerCase() }; - requester('/rest-auth/login/', 'POST', '', data) - .then(res => { - setError({}); - props.setTokenCache(res.key); - window.scrollTo(0, 0); - }) - .catch(err => { - setLoading(false); - console.log(err); - setError(err.data); - }); + if (input.username.includes('@')) { + setError({ username: 'Username, not email.' }); + } else { + if (loading) return; + setLoading(true); + const data = { ...input, username: input.username.toLowerCase() }; + requester('/rest-auth/login/', 'POST', '', data) + .then(res => { + setError({}); + props.setTokenCache(res.key); + window.scrollTo(0, 0); + }) + .catch(err => { + setLoading(false); + console.log(err); + setError(err.data); + }); + } }; return (