mirror of
https://gitlab.com/little-lines/frontend.git
synced 2024-11-22 12:36:53 +00:00
BUG register API
This commit is contained in:
parent
54caf6d3ef
commit
eb55b258d9
2 changed files with 29 additions and 5 deletions
|
@ -45,7 +45,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
login() {
|
login() {
|
||||||
if (this.input.username !== '' || this.input.password !== '') {
|
if (this.input.username !== '' && this.input.password !== '') {
|
||||||
console.log('Authenticated: Checking with Backend');
|
console.log('Authenticated: Checking with Backend');
|
||||||
} else {
|
} else {
|
||||||
console.log('Username and Password cannot be empty');
|
console.log('Username and Password cannot be empty');
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</v-form>
|
</v-form>
|
||||||
</v-container>
|
</v-container>
|
||||||
|
|
||||||
<v-btn @click.prevent="login">สมัครสมาชิค</v-btn>
|
<v-btn @click.prevent="register">สมัครสมาชิค</v-btn>
|
||||||
|
|
||||||
</v-main>
|
</v-main>
|
||||||
</v-app>
|
</v-app>
|
||||||
|
@ -47,15 +47,39 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
login() {
|
register() {
|
||||||
if (this.input.username !== '' || this.input.password !== '') {
|
if (this.input.username !== '' && ((this.input.password !='') && (this.input.password == this.input.passwordConfirm))) {
|
||||||
console.log('Authenticated: Checking with Backend');
|
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 {
|
} else {
|
||||||
console.log('Username and Password cannot be empty');
|
console.log('Username and Password cannot be empty');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue