Commit ea7963e0 authored by Robin Borgogno's avatar Robin Borgogno

adminPrivate

parent 1ccb4a74
let game = {
id: 0
}
module.exports = game
\ No newline at end of file
// export default class user {
// token = "";
// id = 0;
// putId(id)
// {
// this.id = id
// }
// getId()
// {
// return this.id
// }
// putToken(token)
// {
// this.token = token
// }
// getToken()
// {
// return this.token
// }
// }
let user = { let user = {
token: "", token: "",
id: 0 id: 0
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
<div class="row _centered"> <div class="row _centered">
<div class="column _600"> <div class="column _600">
<div class="codeGame"> <div class="codeGame">
<h1 class="titre"> Code de la partie : {{returnID()}}</h1> <h1 class="titre"> Code de la partie :</h1>
<h1 class="titre" id="codeGame">{{idGame()}}{{returnID()}}</h1> <h1 class="titre" id="codeGame">{{gameID()}}</h1>
</div> </div>
<div class="joueurs"> <div class="joueurs">
<!-- ajoute les joueurs présent --> {{JoueurPresent()}}
</div> </div>
</div> </div>
</div> </div>
...@@ -29,10 +29,11 @@ ...@@ -29,10 +29,11 @@
<script> <script>
const user = require("../model/user.js") const user = require("../model/user.js")
const game = require("../model/game.js")
export default { export default {
name: 'AdminPrivate', name: 'AdminPrivate',
methods: { methods: {
idGame: function(){ createIdGame: function(){
const url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/game" const url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/game"
let data = { let data = {
...@@ -43,17 +44,65 @@ export default { ...@@ -43,17 +44,65 @@ export default {
method: 'POST', method: 'POST',
body : JSON.stringify(data) }; body : JSON.stringify(data) };
console.log(user) // console.log(user)
fetch(url, params) fetch(url, params)
.then(response=>response.json()) .then(response=>response.json())
.then(data=>{ .then(data=>{
document.getElementById("codeGame").innerHTML = data[0].id document.getElementById("codeGame").innerHTML = data[0].id;
game.id = data[0].id;
console.log(game.id)
}) })
}, },
returnID: function(){ gameID: function(){
this.createIdGame()
this.ajoutAdminGame()
},
returnUserID: function(){
return user.id return user.id
},
returnGameID: function(){
return game.id
},
ajoutAdminGame: function(){
const url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser"
console.log(this.returnUserID())
console.log(this.returnGameID())
let data = {
"GAME_ID": this.returnGameID(),
"USER_ID": this.returnUserID()
}
var params = {
method: 'POST',
body : JSON.stringify(data) };
fetch(url,params)
.then(response=>response.json())
},
JoueurPresent: function(){
let url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser/game"
url += "/" + game.id;
var params = {
method: "GET"
}
fetch(url,params)
.then(response=>response.json())
.then(data=>{
console.log(data)
let text;
data.forEach(user => {
text += "<h2 class='joueur' id='joueur'>" + user.USER_ID + "</h2>"
});
document.getElementById("joueurs").innerHTML = text
})
} }
}, },
components: {
LoginNavbar
},
} }
import LoginNavbar from '../components/LoginNavbar.vue'
</script> </script>
\ No newline at end of file
...@@ -137,8 +137,6 @@ export default { ...@@ -137,8 +137,6 @@ export default {
fetch(url, params) fetch(url, params)
.then(response=>response.json()) .then(response=>response.json())
.then(data=>console.log(data)) .then(data=>console.log(data))
} }
}, },
......
...@@ -87,10 +87,10 @@ export default { ...@@ -87,10 +87,10 @@ export default {
check: function(){ check: function(){
let login = this.login let login = this.login
let password = this.password let password = this.password
// 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){
......
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