Complain if they log in with email

This commit is contained in:
Tanner Collin 2020-02-16 07:39:36 +00:00
parent a757534061
commit f88256eb74

View File

@ -13,20 +13,24 @@ export function LoginForm(props) {
const handleChange = (e) => handleValues(e, e.currentTarget); const handleChange = (e) => handleValues(e, e.currentTarget);
const handleSubmit = (e) => { const handleSubmit = (e) => {
if (loading) return; if (input.username.includes('@')) {
setLoading(true); setError({ username: 'Username, not email.' });
const data = { ...input, username: input.username.toLowerCase() }; } else {
requester('/rest-auth/login/', 'POST', '', data) if (loading) return;
.then(res => { setLoading(true);
setError({}); const data = { ...input, username: input.username.toLowerCase() };
props.setTokenCache(res.key); requester('/rest-auth/login/', 'POST', '', data)
window.scrollTo(0, 0); .then(res => {
}) setError({});
.catch(err => { props.setTokenCache(res.key);
setLoading(false); window.scrollTo(0, 0);
console.log(err); })
setError(err.data); .catch(err => {
}); setLoading(false);
console.log(err);
setError(err.data);
});
}
}; };
return ( return (