diff options
| author | Pitu <[email protected]> | 2017-01-31 03:43:00 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2017-01-31 03:43:00 -0300 |
| commit | d5c9b15ab97e17e914807b719602f13cec0704ab (patch) | |
| tree | 6095a69f6f9b065e66caf31d65ae0328f5febb05 | |
| parent | Changed /panel to /dashboard (diff) | |
| download | host.fuwn.me-d5c9b15ab97e17e914807b719602f13cec0704ab.tar.xz host.fuwn.me-d5c9b15ab97e17e914807b719602f13cec0704ab.zip | |
Added username display on dashboard
| -rw-r--r-- | controllers/tokenController.js | 2 | ||||
| -rw-r--r-- | pages/dashboard.html | 4 | ||||
| -rw-r--r-- | public/js/dashboard.js | 8 |
3 files changed, 11 insertions, 3 deletions
diff --git a/controllers/tokenController.js b/controllers/tokenController.js index 31b0b3d..7ff7d3f 100644 --- a/controllers/tokenController.js +++ b/controllers/tokenController.js @@ -11,7 +11,7 @@ tokenController.verify = function(req, res, next){ db.table('users').where('token', token).then((user) => { if(user.length === 0) return res.json({ success: false, description: 'Token mismatch' }) - return res.json({ success: true }) + return res.json({ success: true, username: user[0].username}) }).catch(function(error) { console.log(error); res.json({success: false, description: 'error'}) }) } diff --git a/pages/dashboard.html b/pages/dashboard.html index 3b5303d..d4639a4 100644 --- a/pages/dashboard.html +++ b/pages/dashboard.html @@ -54,8 +54,8 @@ <p class="menu-label">Administration</p> <ul class="menu-list"> <li><a id="itemTokens" onclick="panel.changeToken()">Change your token</a></li> - <li><a id="itemTokens" onclick="panel.changePassword()">Change your password</a></li> - <li><a onclick="panel.logout()">Logout</a></li> + <li><a id="itemPassword" onclick="panel.changePassword()">Change your password</a></li> + <li><a id="itemLogout"onclick="panel.logout()">Logout</a></li> </ul> </aside> </div> diff --git a/public/js/dashboard.js b/public/js/dashboard.js index ac53f35..f128c05 100644 --- a/public/js/dashboard.js +++ b/public/js/dashboard.js @@ -1,6 +1,7 @@ let panel = {} panel.page; +panel.username; panel.token = localStorage.token; panel.filesView = localStorage.filesView; @@ -35,6 +36,7 @@ panel.verifyToken = function(token, reloadOnError){ axios.defaults.headers.common['token'] = token; localStorage.token = token; panel.token = token; + panel.username = response.data.username; return panel.prepareDashboard(); }) @@ -62,6 +64,12 @@ panel.prepareDashboard = function(){ panel.setActiveMenu(this); }); + document.getElementById('itemPassword').addEventListener('click', function(){ + panel.setActiveMenu(this); + }); + + document.getElementById('itemLogout').innerHTML = `Logout ( ${panel.username} )`; + panel.getAlbumsSidebar(); } |