Commit 585bc870 authored by Robin Borgogno's avatar Robin Borgogno

adminPrivate

parents ea7963e0 97c6d41d
......@@ -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
......@@ -99,10 +99,19 @@ export default {
})
}
<<<<<<< HEAD
},
components: {
LoginNavbar
},
}
=======
},
components:{
LoginNavbar
}
}
>>>>>>> 97c6d41dc424575a3414673ca6d5e508e1423274
import LoginNavbar from '../components/LoginNavbar.vue'
</script>
\ No newline at end of file
......@@ -90,12 +90,24 @@
</style>
<script>
const user = require("../model/user.js")
export default {
name: 'Inscription',
components: {
LoginNavbar
},
methods: {
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(){
let firstname = this.firstname
let lastname = this.lastname
......@@ -136,11 +148,23 @@ export default {
fetch(url, params)
.then(response=>response.json())
<<<<<<< HEAD
.then(data=>console.log(data))
=======
.then(response=> {
user.token = response.jwt_token
user.id = response.id
})
.then(this.$router.push('/'))
>>>>>>> 97c6d41dc424575a3414673ca6d5e508e1423274
}
},
}
import LoginNavbar from '../components/LoginNavbar.vue'
</script>
......@@ -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,15 +78,22 @@ 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(){
<<<<<<< HEAD
let login = this.login
let password = this.password
=======
let login = this.log
let password = this.pass
>>>>>>> 97c6d41dc424575a3414673ca6d5e508e1423274
var bcrypt = require('bcryptjs');
var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu"
var hash = bcrypt.hashSync(password, salt)
......@@ -94,14 +101,16 @@ export default {
},
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 +119,10 @@ 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)
user.token = response.jwt_token
user.id = response.data.id
})
.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