diff --git a/src/App.js b/src/App.js index 2287c5c..ae706f7 100644 --- a/src/App.js +++ b/src/App.js @@ -608,7 +608,7 @@ function LoginForm(p) { function SubmitLogin() { setError("") setLoading(true) - axios.post(GetBackendURL(p)+"/login",{ + axios.post(GetBackendURL(p)+"/validUser",{ username:username, password:md5(password) }) @@ -619,6 +619,7 @@ function LoginForm(p) { setUsername("") setPassword("") setRememberMe(false) + history.push("/") } else { setError("Could not authenticate!") } @@ -635,11 +636,11 @@ function LoginForm(p) { {loading? - :<>

{error}

+ :<>
{if (f.key==="Enter") {SubmitLogin()}}}>

{error}

{setUsername(p.currentTarget.value)}} placeholder="Username"/>
{setPassword(p.currentTarget.value)}} placeholder="Password"/>
{setRememberMe(p.currentTarget.checked)}}/>
- +
}
} @@ -648,6 +649,7 @@ function RegisterForm(p) { const [username,setUsername] = useState("") const [password,setPassword] = useState("") const [password2,setPassword2] = useState("") + const [email,setEmail] = useState("") const [rememberMe,setRememberMe] = useState(false) const [error,setError] = useState("") const [loading,setLoading] = useState(false) @@ -666,6 +668,7 @@ function RegisterForm(p) { if (username.length>20) {throw "Username must be less than 21 characters in length."} if (password.length<6) {throw "Password must contain at least 6 characters."} if (password!==password2) {throw "Password fields must match."} + if (!email.includes("@")) {throw "Invalid E-mail."} }catch(err){ setError(err) setLoading(false) @@ -673,7 +676,8 @@ function RegisterForm(p) { } axios.post(GetBackendURL(p)+"/register",{ username:username, - password:md5(password) + password:md5(password), + email:email }) .then((data)=>{ if (data.data.verified) { @@ -699,9 +703,10 @@ function RegisterForm(p) { {loading? :<>

{error}

- {setUsername(p.currentTarget.value)}} placeholder="Username" tooltip="Enter a username (4-20 characters, alphanumeric only)"/>
+ {setUsername(p.currentTarget.value)}} placeholder="Username" tooltip="Enter a username (4-20 characters, a-z and _ only)"/>
{setPassword(p.currentTarget.value)}} placeholder="Password" tooltip="Enter a password (6 or more characters)"/>
{setPassword2(p.currentTarget.value)}} placeholder="Verify Password" tooltip="Enter password again."/>
+ {setEmail(p.currentTarget.value)}} placeholder="email@example.com" tooltip="This is used to send you password reset emails."/>
{setRememberMe(p.currentTarget.checked)}}/>
} @@ -747,8 +752,8 @@ function App() { const [DATA,setDATA] = useState({GetData:()=>{}}) const [DATAID,setDATAID] = useState({GetData:()=>{}}) - const [LOGGEDINUSER,setLOGGEDINUSER] = useState("sigonasr2") - const [LOGGEDINHASH,setLOGGEDINHASH] = useState("7355ddfc5b81291cdd2c3025976c108c") + const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") + const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") function GetData(table,row,col,id){