diff --git a/src/views/Login.vue b/src/views/Login.vue
index dc7363e..a97e54f 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -45,7 +45,7 @@ export default {
},
methods: {
login() {
- if (this.input.username !== '' || this.input.password !== '') {
+ if (this.input.username !== '' && this.input.password !== '') {
console.log('Authenticated: Checking with Backend');
} else {
console.log('Username and Password cannot be empty');
diff --git a/src/views/Register.vue b/src/views/Register.vue
index 9ce0491..02c35c2 100644
--- a/src/views/Register.vue
+++ b/src/views/Register.vue
@@ -21,7 +21,7 @@
- สมัครสมาชิค
+ สมัครสมาชิค
@@ -47,15 +47,39 @@
};
},
methods: {
- login() {
- if (this.input.username !== '' || this.input.password !== '') {
+ register() {
+ if (this.input.username !== '' && ((this.input.password !='') && (this.input.password == this.input.passwordConfirm))) {
console.log('Authenticated: Checking with Backend');
+ fetch("http://localhost:5000/api/users/create", {
+ method: "POST",
+ body: JSON.stringify({
+ username: username,
+ password: password,
+ email: "",
+ isGoogleAccount: false
+ })
+ })
+ .then((res) => {
+ if(res.ok){
+ return res.json()
+ }
+ else{
+ return res.json().then(data => {throw Error(`${data.registerStatus}`) });
+ }
+ })
+ .then((data) => {
+ console.log(data.registerStatus)
+ this.$router.push({name : 'login'})
+ })
+ .catch((err) =>{
+ console.log(err)
+ })
+ console.log("fisnished fetch");
} else {
console.log('Username and Password cannot be empty');
}
}
}
};
-
\ No newline at end of file