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

Errors

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