Commit 2e179154 authored by Thiwanka K.A.T's avatar Thiwanka K.A.T 🎯

Merge branch 'IT19076362' into 'master'

It19076362

See merge request !110
parents 7bcede41 c5011a16
No preview for this file type
...@@ -26,9 +26,6 @@ def register(): ...@@ -26,9 +26,6 @@ def register():
if len(password) < 6: if len(password) < 6:
return jsonify({'err': "Password is too short"}), HTTP_400_BAD_REQUEST return jsonify({'err': "Password is too short"}), HTTP_400_BAD_REQUEST
if not username.isalnum() or " " in username:
return jsonify({'err': "Username should be alphanumeric, also no spaces"}), HTTP_400_BAD_REQUEST
if not validators.email(email): if not validators.email(email):
return jsonify({'err': "Email is not valid"}), HTTP_400_BAD_REQUEST return jsonify({'err': "Email is not valid"}), HTTP_400_BAD_REQUEST
...@@ -60,9 +57,6 @@ def login(): ...@@ -60,9 +57,6 @@ def login():
if not username or not password: if not username or not password:
return jsonify({'err': 'Missing email or password'}), HTTP_400_BAD_REQUEST return jsonify({'err': 'Missing email or password'}), HTTP_400_BAD_REQUEST
if not username.isalnum() or " " in username:
return jsonify({'err': "Username should be alphanumeric, also no spaces"}), HTTP_400_BAD_REQUEST
user = User.query.filter_by(username=username).first() user = User.query.filter_by(username=username).first()
if user is None: if user is None:
......
...@@ -16,6 +16,7 @@ const Login = () => { ...@@ -16,6 +16,7 @@ const Login = () => {
username: "", username: "",
password: "", password: "",
email: "", email: "",
type: "student",
}); });
const registerUser = async e => { const registerUser = async e => {
...@@ -25,21 +26,15 @@ const Login = () => { ...@@ -25,21 +26,15 @@ const Login = () => {
setSuccess(false); setSuccess(false);
try { try {
const res = await axios.post("register", user); const res = await axios.post("auth/register", user);
if (res.statusText === "Created") { setBtnState(false);
setUser({ window.alert("You are registered. Please login to continue");
username: "", setSuccess("You are registered. Thank you");
password: "", return window.location.replace("/login");
email: "",
});
setBtnState(false);
return setSuccess("You are registered. Thank you");
}
} catch (err) { } catch (err) {
console.log(err.response); console.log(err.response);
setError(err.response.data.message); setError(err.response.data.err);
setBtnState(false); setBtnState(false);
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment