upd: build.router.controller (add _SERVER.session.connected)

upd: public_html.header = (add icon logout)
upd: public_html.signup-form (add backlink to login)
upd: view.vue.header = (change icon if connected or not)
upd: view.vue.signup-form = (add backling to login)
This commit is contained in:
Guillaume FAUVET 2017-12-08 01:22:03 +01:00 committed by SeekDaSky
parent 90c05624ab
commit c0013f25b0
5 changed files with 39 additions and 4 deletions

View File

@ -26,7 +26,8 @@
echo "window._SERVER = ".json_encode([ echo "window._SERVER = ".json_encode([
'session' => [ 'session' => [
'name' => $_SESSION['NAME'] 'name' => $_SESSION['NAME'],
'connected' => count($_SESSION['ADMIN']) + count($_SESSION['USER']) > 0
] ]
])."\n"; ])."\n";

View File

@ -116,6 +116,7 @@
#header-notif .hnotif.search{ background-image: url('/image/header/notif/search.svg@aaaaaa'); } #header-notif .hnotif.search{ background-image: url('/image/header/notif/search.svg@aaaaaa'); }
#header-notif .hnotif.menu{ background-image: url('/image/header/notif/menu.svg@aaaaaa'); } #header-notif .hnotif.menu{ background-image: url('/image/header/notif/menu.svg@aaaaaa'); }
#header-notif .hnotif.login{ background-image: url('/image/header/notif/login.svg@aaaaaa'); } #header-notif .hnotif.login{ background-image: url('/image/header/notif/login.svg@aaaaaa'); }
#header-notif .hnotif.logout{ background-image: url('/image/header/notif/logout.svg@aaaaaa'); }
/* HOVER */ /* HOVER */
#header-notif .hnotif:hover{ #header-notif .hnotif:hover{
@ -129,6 +130,7 @@
#header-notif .hnotif.search:hover{ background-image: url('/image/header/notif/search.svg@ae51da'); } #header-notif .hnotif.search:hover{ background-image: url('/image/header/notif/search.svg@ae51da'); }
#header-notif .hnotif.menu:hover{ background-image: url('/image/header/notif/menu.svg@4a8ad8'); } #header-notif .hnotif.menu:hover{ background-image: url('/image/header/notif/menu.svg@4a8ad8'); }
#header-notif .hnotif.login:hover{ background-image: url('/image/header/notif/login.svg@660088'); } #header-notif .hnotif.login:hover{ background-image: url('/image/header/notif/login.svg@660088'); }
#header-notif .hnotif.logout:hover{ background-image: url('/image/header/notif/logout.svg@660088'); }

View File

@ -107,3 +107,10 @@
border-width: 1px; border-width: 1px;
outline: none; outline: none;
} }
#SIGNUP-FORM > .body > form > #membre{
font-size: 0.8em;
color: #006eff;
text-decoration: underline;
margin-top: 8px;
}

View File

@ -13,7 +13,8 @@
<!-- Header Notif --> <!-- Header Notif -->
<div id='header-notif'> <div id='header-notif'>
<div v-for='(notif, link) in gstore.notif' @click='show_notif(link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div> <div v-for='(notif, link) in gstore.notif' @click='show_notif(link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
<div @click='show_login()' class='hnotif login'></div> <div v-if='!is_connected' @click='show_login()' class='hnotif login'></div>
<div v-if='is_connected' @click='logout()' class='hnotif logout'></div>
</div> </div>
</div> </div>
@ -24,7 +25,12 @@
<script> <script>
export default { export default {
name: 'HEADER', name: 'HEADER',
data(){ return { gstore: gstore.data }; }, data(){
return {
gstore: gstore.data,
is_connected: _SERVER.session.connected
};
},
methods: { methods: {
show_notif(uri){ show_notif(uri){
this.gstore.func.nav(this.$router, uri); this.gstore.func.nav(this.$router, uri);
@ -32,6 +38,11 @@ export default {
show_login() { show_login() {
this.gstore.signupform = false; this.gstore.signupform = false;
this.gstore.loginform = !this.gstore.loginform; this.gstore.loginform = !this.gstore.loginform;
},
logout() {
api.call('DELETE user/logout', null, function() {
document.location = '';
});
} }
} }
} }

View File

@ -19,6 +19,7 @@
<input v-model='password_val' type='password' id='password'> <input v-model='password_val' type='password' id='password'>
<p v-if='err_username || err_mail || err_unknow' id='msg-err'>{{ err_message }}</p> <p v-if='err_username || err_mail || err_unknow' id='msg-err'>{{ err_message }}</p>
<button id='btn-create-account'>Créer mon compte</button> <button id='btn-create-account'>Créer mon compte</button>
<p @click='redirect_login' id='membre'>Déjà membre ? Connectez-vous !</p>
</form> </form>
</div> </div>
@ -72,9 +73,22 @@
} }
/* (2) Close the sign up form authentication */ /* (2) Close the sign up form authentication */
else { else {
document.location = ''; this.infobox._display('Inscription terminée ! Connexion en cours ...', 'info', 3000);
let request = {
username: this.username_val,
password: this.password_val
};
api.call("POST user/login", request, function (response) {
document.location = '';
});
} }
}.bind(this)); }.bind(this));
},
redirect_login() {
this.gstore.signupform = false;
this.gstore.loginform = true;
} }
} }
} }