Commit 61df9385 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

add sign up module

parent 927c9a8a
export default function(context) {
console.log('[LOG]: middleware is running ...')
}
\ No newline at end of file
import http from 'http'
export default function ({ route }) {
return http.post('http://my-stats-api.com', {
url: route.fullPath
})
}
\ No newline at end of file
...@@ -41,7 +41,12 @@ export default { ...@@ -41,7 +41,12 @@ export default {
modules: [ modules: [
// https://go.nuxtjs.dev/bootstrap // https://go.nuxtjs.dev/bootstrap
'bootstrap-vue/nuxt', 'bootstrap-vue/nuxt',
'@nuxtjs/axios',
'@nuxtjs/auth-next',
], ],
auth: {
// Options
},
// Build Configuration: https://go.nuxtjs.dev/config-build // Build Configuration: https://go.nuxtjs.dev/config-build
build: { build: {
......
This diff is collapsed.
...@@ -9,13 +9,21 @@ ...@@ -9,13 +9,21 @@
"generate": "nuxt generate" "generate": "nuxt generate"
}, },
"dependencies": { "dependencies": {
"@nuxtjs/auth-next": "5.0.0-1667386184.dfbbb54",
"@nuxtjs/axios": "^5.13.6",
"axios": "^1.2.1",
"bootstrap": "^4.6.2", "bootstrap": "^4.6.2",
"bootstrap-vue": "^2.22.0", "bootstrap-vue": "^2.23.1",
"core-js": "^3.25.3", "core-js": "^3.25.3",
"jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.0",
"nuxt": "^2.15.8", "nuxt": "^2.15.8",
"prism-themes": "^1.9.0",
"vue": "^2.7.10", "vue": "^2.7.10",
"vue-server-renderer": "^2.7.10", "vue-server-renderer": "^2.7.10",
"vue-template-compiler": "^2.7.10" "vue-template-compiler": "^2.7.10"
},
"devDependencies": {
"sass": "^1.57.1",
"sass-loader": "^10.4.1"
} }
} }
...@@ -3,20 +3,32 @@ ...@@ -3,20 +3,32 @@
</template> </template>
<script> <script>
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import axios from 'axios';
import VueAxios from 'vue-axios';
export default { // export default {
name: "Home", // name: "Home",
setup() { // data() {
onMounted(async ()=> { // return {
await fetch('http://localhost:3000/api/', { // users: [],
method: 'POST', // }
headers: {'Content-Type': 'application/json'}, // },
credentials: 'include', // setup() {
}); // onMounted(async ()=> {
}) // await fetch('http://localhost:3000/api/login', {
} // method: 'GET',
} // headers: {'Content-Type': 'application/json'},
</script> // data: Response.data,
// credentials: 'include',
// });
// })
// }
// }
// </script>
// <script>
// console.log(data);
// </script>
<style> <style>
</style> </style>
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
}, },
methods: { methods: {
login() { login() {
fetch("http://localhost:3000/login", { fetch("http://127.0.0.1:8000/api/login", {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
...@@ -94,6 +94,7 @@ export default { ...@@ -94,6 +94,7 @@ export default {
password: this.password, password: this.password,
}), }),
}); });
this.$router.push('home');
}, },
}, },
}; };
......
<template>
<div class="container"
style="
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
">
<div id="form-group">
<form @submit.prevent="signin">
<label>Name :</label>
<input type="text" class="form-control"
placeholder="name" v-model="name" required>
<label>Email :</label>
<input type="email" class="form-control"
placeholder="Email" v-model="email" required>
<label>Password :</label>
<input type="password"
class="form-control"
placeholder="password" v-model="password" required>
<label>Confirm Password :</label>
<input type="password"
class="form-control"
placeholder="Confirm_password" required>
<div class="button">
<button class="submit" type="submit">Sign up here</button>
</div>
</form>
</div>
</div>
</template>
<script>
import { reactive } from "vue";
export default {
data: () => {
return {
name: "",
email: "",
password: "",
};
},
methods: {
signin() {
fetch("http://127.0.0.1:8000/api/register", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: this.name,
email: this.email,
password: this.password,
}),
});
this.$router.push('/');
},
},
};
</script>
<style scoped>
#form-group {
height: 50%;
width: 50%;
border: 1px solid black;
padding: 12px;
padding-top: 60px;
display: flex;
justify-content: center;
background-color: #17a2b8;
border-radius: 10%;
font-weight: 600;
}
</style>
\ No newline at end of file
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