Commit c2820a9c authored by raphael.peim's avatar raphael.peim

Modify classnames

parent 109dd0b0
...@@ -38,10 +38,11 @@ ...@@ -38,10 +38,11 @@
"iat" => $issued_at, "iat" => $issued_at,
"exp" => $expiration_time, "exp" => $expiration_time,
"iss" => JWT_ISSUER, "iss" => JWT_ISSUER,
"data" => array(
"id" => $user->id, "id" => $user->id,
"data" => array(
"firstname" => $user->firstname, "firstname" => $user->firstname,
"lastname" => $user->lastname, "lastname" => $user->lastname,
"lastname" => $user->login,
"email" => $user->email "email" => $user->email
) )
); );
......
...@@ -39,10 +39,12 @@ ...@@ -39,10 +39,12 @@
components: {}, components: {},
methods: { methods: {
onClick() { onClick() {
if (confirm("Etes-vous sûr de vouloir vous déconnecter ?")) if (confirm("Etes-vous sûr de vouloir vous déconnecter ?")) {
localStorage.clear()
window.location.href = '/#/' window.location.href = '/#/'
} }
} }
}
}; };
</script> </script>
......
...@@ -11,7 +11,34 @@ Vue.use(BootstrapVue) ...@@ -11,7 +11,34 @@ Vue.use(BootstrapVue)
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$hostname = Vue.config.productionTip ? 'https://hostname' : 'http://localhost:8080' Vue.prototype.$hostname = Vue.config.productionTip ? 'https://hostname' : 'http://localhost:8080'
Vue.prototype.$apiUrl = 'http://localhost:8888/IMT/CDAW/frontend/public/api/api.php' Vue.prototype.$apiUrl = 'http://localhost:8888/IMT/CDAW/frontend/public/api/api.php'
Vue.prototype.$token = ""
Vue.mixin({
created: function () {
if (localStorage.token === undefined && this.$route.name != 'Index' && this.$route.name != 'Signup') {
window.location.href = '/#/'
}
else if (localStorage.token !== undefined && (this.$route.name == 'Index' || this.$route.name == 'Signup')) {
window.location.href = '/#/home'
}
},
methods: {
isExpired() {
fetch(this.$apiUrl + '/validatetoken', {
method: 'GET',
header: {
'Authorization' : 'Bearer ' + localStorage.token
}
})
.then(response => {
if (response.status === 200) {
return false
} else {
window.location.href = '/#/'
}
})
}
}
})
new Vue({ new Vue({
router, router,
......
...@@ -2,7 +2,15 @@ ...@@ -2,7 +2,15 @@
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center"> <div class="center">
<img src="../assets/img/game.png" class="img-fluid" alt="Responsive image"> <!-- <img src="../assets/img/game.png" class="img-fluid" alt="Responsive image"> -->
<div id="game" class="container">
<div class="row">
<div id="chat" class="col-4">
</div>
<div id="play" class="col-10">
</div>
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
...@@ -17,3 +25,23 @@ ...@@ -17,3 +25,23 @@
} }
} }
</script> </script>
<style>
#game {
display: flex;
height: 50px;
border: 1px solid black;
}
#chat {
/* display: flex; */
/* width: 20%; */
height: 50px;
border: 1px solid black;
}
#play {
/* display: flex; */
/* width: 80%; */
height: 50px;
border: 1px solid black;
}
</style>
\ No newline at end of file
<template> <template>
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center"> <div class="container d-flex justify-content-center">
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">Choisissez le mode</h5> <h5 class="card-header text-primary">Choisissez le mode</h5>
<div class="card-body" style="width : 500px;"> <div class="card-body" style="width : 500px;">
......
<template> <template>
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center"> <div class="container d-flex justify-content-center">
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">Créer une partie</h5> <h5 class="card-header text-primary">Créer une partie</h5>
<div class="card-body" style="width : 500px;"> <div class="card-body" style="width : 500px;">
......
<template> <template>
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center"> <div class="container d-flex justify-content-center">
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">Rejoindre une partie</h5> <h5 class="card-header text-primary">Rejoindre une partie</h5>
<div class="card-body" style="width : 500px;"> <div class="card-body" style="width : 500px;">
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<button type="button" class="btn btn-primary btn-block">Commencer</button> <button type="button" class="btn btn-primary btn-block">Commencer</button>
</router-link> </router-link>
</form> </form>
<form style="margin-top: 50px;"> <form>
<h5>Sans identifiant :</h5> <h5>Sans identifiant :</h5>
<router-link to="/game"> <router-link to="/game">
<button type="button" class="btn btn-primary btn-block">Trouver une partie</button> <button type="button" class="btn btn-primary btn-block">Trouver une partie</button>
...@@ -41,3 +41,9 @@ ...@@ -41,3 +41,9 @@
} }
} }
</script> </script>
<style>
form:nth-of-type(2) {
margin-top: 50px;
}
</style>
\ No newline at end of file
<template> <template>
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center" style="justify-content: space-around;"> <div class="container">
<div class="row">
<div class="col d-flex justify-content-center">
<router-link to="/rules"><b-button variant="primary">Découvrir le mahjong</b-button></router-link> <router-link to="/rules"><b-button variant="primary">Découvrir le mahjong</b-button></router-link>
</div>
<div class="col d-flex justify-content-center">
<router-link to="/gameChoice"><b-button variant="primary">Commercer à jouer</b-button></router-link> <router-link to="/gameChoice"><b-button variant="primary">Commercer à jouer</b-button></router-link>
</div> </div>
</div> </div>
</div>
</div>
</template> </template>
<script> <script>
......
...@@ -77,8 +77,11 @@ ...@@ -77,8 +77,11 @@
let areEqual = bcrypt.compareSync(form.elements.password.value, row.password) let areEqual = bcrypt.compareSync(form.elements.password.value, row.password)
if (areEqual) { if (areEqual) {
this.getToken(row.login, row.password) // Enregistrement du token et redirection
this.getToken(row.login, row.password).then(token => {
localStorage.setItem('token', token)
window.location.href = "/#/home" window.location.href = "/#/home"
});
} }
else { else {
document.querySelector('#message').innerHTML = "Mauvais mot de passe" document.querySelector('#message').innerHTML = "Mauvais mot de passe"
...@@ -92,6 +95,7 @@ ...@@ -92,6 +95,7 @@
}); });
}, },
getToken(login, password) { getToken(login, password) {
return new Promise((resolve, reject) => {
fetch(this.$apiUrl + '/login', { fetch(this.$apiUrl + '/login', {
method: 'POST', method: 'POST',
body: JSON.stringify({ login: login, password: password }) body: JSON.stringify({ login: login, password: password })
...@@ -104,10 +108,13 @@ ...@@ -104,10 +108,13 @@
} }
}) })
.then(data => { .then(data => {
console.log(data.jwt_token) // Envoie du token
resolve(data.jwt_token)
}).catch(error => { }).catch(error => {
console.error(error) console.error(error)
console.error(reject)
}); });
})
} }
} }
} }
......
<template> <template>
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center"> <div class="container d-flex justify-content-center">
<h1>Les règles</h1> <h1>Les règles</h1>
</div> </div>
</div> </div>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="card-body p-0"> <div class="card-body p-0">
<div class="row"> <div class="row">
<div class="col-lg-6 d-none d-lg-block bg-login-image"> <div class="col-lg-6 d-none d-lg-block bg-login-image">
<img src="../assets/img/log.png" class="img-fluid" alt="Responsive image"> <img src="../assets/img/log.png" class="img-fluid h-100 d-inline-block" alt="Responsive image">
</div> </div>
<div class="col-lg-6"> <div class="col-lg-6">
<div class="p-5"> <div class="p-5">
......
<template> <template>
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="center"> <div class="container d-flex justify-content-center">
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">En attente de joueurs</h5> <h5 class="card-header text-primary">En attente de joueurs</h5>
<div class="card-body" style="width : 500px;"> <div class="card-body" style="width : 500px;">
......
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