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

Modify classnames

parent 109dd0b0
......@@ -38,10 +38,11 @@
"iat" => $issued_at,
"exp" => $expiration_time,
"iss" => JWT_ISSUER,
"data" => array(
"id" => $user->id,
"data" => array(
"firstname" => $user->firstname,
"lastname" => $user->lastname,
"lastname" => $user->login,
"email" => $user->email
)
);
......
......@@ -39,10 +39,12 @@
components: {},
methods: {
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 = '/#/'
}
}
}
};
</script>
......
......@@ -11,7 +11,34 @@ Vue.use(BootstrapVue)
Vue.config.productionTip = false
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.$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({
router,
......
......@@ -2,7 +2,15 @@
<div class="body">
<Navbar/>
<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>
</template>
......@@ -17,3 +25,23 @@
}
}
</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>
<div class="body">
<Navbar/>
<div class="center">
<div class="container d-flex justify-content-center">
<div class="card shadow mb-4">
<h5 class="card-header text-primary">Choisissez le mode</h5>
<div class="card-body" style="width : 500px;">
......
<template>
<div class="body">
<Navbar/>
<div class="center">
<div class="container d-flex justify-content-center">
<div class="card shadow mb-4">
<h5 class="card-header text-primary">Créer une partie</h5>
<div class="card-body" style="width : 500px;">
......
<template>
<div class="body">
<Navbar/>
<div class="center">
<div class="container d-flex justify-content-center">
<div class="card shadow mb-4">
<h5 class="card-header text-primary">Rejoindre une partie</h5>
<div class="card-body" style="width : 500px;">
......@@ -12,7 +12,7 @@
<button type="button" class="btn btn-primary btn-block">Commencer</button>
</router-link>
</form>
<form style="margin-top: 50px;">
<form>
<h5>Sans identifiant :</h5>
<router-link to="/game">
<button type="button" class="btn btn-primary btn-block">Trouver une partie</button>
......@@ -41,3 +41,9 @@
}
}
</script>
<style>
form:nth-of-type(2) {
margin-top: 50px;
}
</style>
\ No newline at end of file
<template>
<div class="body">
<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>
</div>
<div class="col d-flex justify-content-center">
<router-link to="/gameChoice"><b-button variant="primary">Commercer à jouer</b-button></router-link>
</div>
</div>
</div>
</div>
</template>
<script>
......
......@@ -77,8 +77,11 @@
let areEqual = bcrypt.compareSync(form.elements.password.value, row.password)
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"
});
}
else {
document.querySelector('#message').innerHTML = "Mauvais mot de passe"
......@@ -92,6 +95,7 @@
});
},
getToken(login, password) {
return new Promise((resolve, reject) => {
fetch(this.$apiUrl + '/login', {
method: 'POST',
body: JSON.stringify({ login: login, password: password })
......@@ -104,10 +108,13 @@
}
})
.then(data => {
console.log(data.jwt_token)
// Envoie du token
resolve(data.jwt_token)
}).catch(error => {
console.error(error)
console.error(reject)
});
})
}
}
}
......
<template>
<div class="body">
<Navbar/>
<div class="center">
<div class="container d-flex justify-content-center">
<h1>Les règles</h1>
</div>
</div>
......
......@@ -4,7 +4,7 @@
<div class="card-body p-0">
<div class="row">
<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 class="col-lg-6">
<div class="p-5">
......
<template>
<div class="body">
<Navbar/>
<div class="center">
<div class="container d-flex justify-content-center">
<div class="card shadow mb-4">
<h5 class="card-header text-primary">En attente de joueurs</h5>
<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