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

ajout var user

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