2023-08-31 20:35:39 +00:00
|
|
|
<template>
|
|
|
|
|
|
|
|
<v-app>
|
|
|
|
<top-bar :show-back-icon="true" :page-title="pageTitle" />
|
|
|
|
<v-main>
|
|
|
|
<v-container>
|
|
|
|
<v-form name="register-form">
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="username">Username: </label>
|
|
|
|
<input type="text" id="username" v-model="input.username" />
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="password">Password: </label>
|
|
|
|
<input type="password" id="password" v-model="input.password" />
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="password">Password Confirmation: </label>
|
2023-08-31 20:55:00 +00:00
|
|
|
<input type="password" id="passwordConfirm" v-model="input.passwordConfirm" />
|
2023-08-31 20:35:39 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</v-form>
|
|
|
|
</v-container>
|
|
|
|
|
2023-09-24 11:35:25 +00:00
|
|
|
<v-btn @click.prevent="register">สมัครสมาชิค</v-btn>
|
2023-08-31 20:35:39 +00:00
|
|
|
|
|
|
|
</v-main>
|
|
|
|
</v-app>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import TopBar from '@/components/TopBar.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
TopBar
|
|
|
|
},
|
|
|
|
name: 'register',
|
|
|
|
data() {
|
|
|
|
return {
|
2023-08-31 20:55:00 +00:00
|
|
|
pageTitle: 'สมัครสมาชิค',
|
2023-08-31 20:35:39 +00:00
|
|
|
input: {
|
|
|
|
username: '',
|
|
|
|
password: '',
|
|
|
|
passwordConfirm:''
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
2023-09-24 11:35:25 +00:00
|
|
|
register() {
|
|
|
|
if (this.input.username !== '' && ((this.input.password !='') && (this.input.password == this.input.passwordConfirm))) {
|
2023-08-31 20:35:39 +00:00
|
|
|
console.log('Authenticated: Checking with Backend');
|
2023-09-30 05:01:28 +00:00
|
|
|
fetch("http://test.techtransthai.org:5001/api/users/create", {
|
2023-09-24 11:35:25 +00:00
|
|
|
method: "POST",
|
2023-09-26 17:47:59 +00:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
},
|
2023-09-24 11:35:25 +00:00
|
|
|
body: JSON.stringify({
|
2023-09-26 17:47:59 +00:00
|
|
|
username: this.input.username,
|
|
|
|
password: this.input.password,
|
|
|
|
email: "asdf",
|
2023-09-24 11:35:25 +00:00
|
|
|
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");
|
2023-08-31 20:35:39 +00:00
|
|
|
} else {
|
|
|
|
console.log('Username and Password cannot be empty');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|