Commit 8f9e8061 authored by Robin Borgogno's avatar Robin Borgogno

ajout var user

parent 524a663b
......@@ -47,7 +47,8 @@ class LoginController extends Controller {
$jwt = JWT::encode( $token, JWT_BACKEND_KEY );
$jsonResult = json_encode(
array(
"jwt_token" => $jwt
"jwt_token" => $jwt,
"data" => $token['data']
)
);
......
export default class user {
token = "";
id = 0;
// export default class user {
// token = "";
// id = 0;
putId(id)
{
this.id = id
}
// putId(id)
// {
// this.id = id
// }
getId()
{
return this.id
}
// getId()
// {
// return this.id
// }
putToken(token)
{
this.token = token
}
// putToken(token)
// {
// this.token = token
// }
getToken()
{
return this.token
}
// getToken()
// {
// return this.token
// }
}
\ No newline at end of file
// }
let user = {
token: "",
id: 0
}
module.exports = user
\ No newline at end of file
......@@ -4,8 +4,8 @@
<div class="row _centered">
<div class="column _600">
<div class="codeGame">
<h1 class="titre"> Code de la partie : </h1>
<h1 class="titre" id="codeGame">{{idGame()}}</h1>
<h1 class="titre"> Code de la partie : {{returnID()}}</h1>
<h1 class="titre" id="codeGame">{{idGame()}}{{returnID()}}</h1>
</div>
<div class="joueurs">
<!-- ajoute les joueurs présent -->
......@@ -28,6 +28,7 @@
</style>
<script>
const user = require("../model/user.js")
export default {
name: 'AdminPrivate',
methods: {
......@@ -41,6 +42,8 @@ export default {
var params = {
method: 'POST',
body : JSON.stringify(data) };
console.log(user)
fetch(url, params)
.then(response=>response.json())
......@@ -48,6 +51,9 @@ export default {
document.getElementById("codeGame").innerHTML = data[0].id
})
},
returnID: function(){
return user.id
}
},
}
</script>
\ No newline at end of file
......@@ -74,7 +74,7 @@
</style>
<script>
const user = require("../model/user.js")
export default {
name: 'Login',
......@@ -82,10 +82,10 @@ export default {
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, hash)
// var bcrypt = require('bcryptjs');
// var salt = "$2a$08$c0GzKSB8g6.rZLF98GJvQu"
// var hash = bcrypt.hashSync(password, salt)
this.call(login, password)
},
call: function(login, password){
......@@ -99,23 +99,23 @@ export default {
var params = {
method: 'POST',
body : JSON.stringify(data) };
body : JSON.stringify(data)
};
fetch(url, params)
.then(response=>response.json())
.then(response => {
sessionStorage.setItem("JWT_TOKEN", response.data.jwt_token)
console.log(sessionStorage.getItem("JWT_TOKEN"))
user.token = response.jwt_token
user.id = response.data.id
console.log(response)
})
}
},
components: {
},
components: {
LoginNavbar
},
}
},
}
import LoginNavbar from '../components/LoginNavbar.vue'
</script>
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