mirror of
https://gitlab.com/little-lines/frontend.git
synced 2024-11-22 05:36:51 +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: {
|
||||
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');
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</v-form>
|
||||
</v-container>
|
||||
|
||||
<v-btn @click.prevent="login">สมัครสมาชิค</v-btn>
|
||||
<v-btn @click.prevent="register">สมัครสมาชิค</v-btn>
|
||||
|
||||
</v-main>
|
||||
</v-app>
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in a new issue