Commit 0a5da1e0 authored by thibaut-felten's avatar thibaut-felten

Errors

parent 1ccb4a74
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<button class="btn-login"> <button class="btn-login">
<router-link to="/">Accueil</router-link> <router-link to="/">Accueil</router-link>
</button> </button>
<button class="btn-login" v-if="connected"> <button class="btn-login" v-if="user.id==0">
<router-link to="/inscription">Sign Up</router-link> <router-link to="/inscription">Inscription</router-link>
</button> </button>
<button class="btn-login" v-if="connected"> <button class="btn-login" v-if="user.id==0">
<router-link to="/login">Log In</router-link> <router-link to="/login">Connection</router-link>
</button> </button>
</nav> </nav>
...@@ -15,16 +15,21 @@ ...@@ -15,16 +15,21 @@
<script> <script>
const user = require("../model/user.js")
export default { export default {
name: 'LoginNavbar', name: 'LoginNavbar',
data(){ // the data, declared as function data(){ // the data, declared as function
return{ // we return all the properties that should be react on. return{ // we return all the properties that should be react on.
connected:true user
} }
}, },
} }
console.log(user.id);
</script> </script>
<style scoped> <style scoped>
......
...@@ -45,7 +45,13 @@ export default { ...@@ -45,7 +45,13 @@ export default {
components: { components: {
LoginNavbar LoginNavbar
}, },
data(){ // the data, declared as function
return{ // we return all the properties that should be react on.
user
}
},
} }
const user=require(("../model/user.js"))
import LoginNavbar from '../components/LoginNavbar.vue' import LoginNavbar from '../components/LoginNavbar.vue'
</script> </script>
\ No newline at end of file
...@@ -54,6 +54,11 @@ export default { ...@@ -54,6 +54,11 @@ export default {
returnID: function(){ returnID: function(){
return user.id return user.id
} }
}, },
components:{
LoginNavbar
}
} }
import LoginNavbar from '../components/LoginNavbar.vue'
</script> </script>
\ No newline at end of file
...@@ -94,6 +94,16 @@ export default { ...@@ -94,6 +94,16 @@ export default {
name: 'Inscription', name: 'Inscription',
components: { components: {
LoginNavbar LoginNavbar
},
data(){ // the data, declared as function
return{ // we return all the properties that should be react on.
firstname:"",
lastname:"",
login:"",
email:"",
password:"",
confirmpassword:""
}
}, },
methods: { methods: {
check: function(){ check: function(){
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
<form id="loginForm" class="form" v-on:submit.prevent="check"> <form id="loginForm" class="form" v-on:submit.prevent="check">
<div class="row lpad"> <div class="row lpad">
<label for="Login"> Login </label> <label for="Login"> Login </label>
<input v-model="login" type="text" name="Login" id="loginValue" required> <input v-model="log" type="text" name="Login" id="loginValue" required>
</div> </div>
<div class="row lpad"> <div class="row lpad">
<label for="Password"> Mot de passe </label> <label for="Password"> Mot de passe </label>
<input v-model="password" type="password" name="Password" id="passwordValue" required> <input v-model="pass" type="password" name="Password" id="passwordValue" required>
</div> </div>
<div class="row lpad"> <div class="row lpad">
<button type="submit" class="btn"> Valider </button> <button type="submit" class="btn"> Valider </button>
...@@ -78,30 +78,34 @@ const user = require("../model/user.js") ...@@ -78,30 +78,34 @@ const user = require("../model/user.js")
export default { export default {
name: 'Login', name: 'Login',
data(connect){ // the data, declared as function data(){ // the data, declared as function
return{ // we return all the properties that should be react on. return{ // we return all the properties that should be react on.
connected:connect log: '',
} pass: ''
}
}, },
methods: { methods: {
check: function(){ check: function(){
let login = this.login let login = this.log
let password = this.password let password = this.pass
// var bcrypt = require('bcryptjs'); var bcrypt = require('bcryptjs');
// var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu" var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu"
// var hash = bcrypt.hashSync(password, salt) var hash = bcrypt.hashSync(password, salt)
this.call(login, password) this.call(login, hash)
}, },
call: function(login, password){ call: function(login, password){
const url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/login" const url = "http://localhost/projet-cdaw/backend/MVC/api.php/login"
// Robin config
// const url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/login"
let data = { let data = {
login: login, login: login,
pwd: password pwd: password
} }
var params = { var params = {
method: 'POST', method: 'POST',
body : JSON.stringify(data) body : JSON.stringify(data)
...@@ -110,11 +114,12 @@ export default { ...@@ -110,11 +114,12 @@ export default {
fetch(url, params) fetch(url, params)
.then(response=>response.json()) .then(response=>response.json())
.then(response => { .then(response => {
sessionStorage.setItem("JWT_TOKEN", response.data.jwt_token) console.log(response)
user.token = response.jwt_token user.token = response.jwt_token
user.id = response.data.id user.id = response.data.id
console.log(response) console.log(user)
}) })
.then(this.$router.push("/"))
} }
}, },
components: { components: {
......
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