diff --git a/client/salix/src/components/main-menu/main-menu.html b/client/salix/src/components/main-menu/main-menu.html
index 99edd2f3f..863585baa 100644
--- a/client/salix/src/components/main-menu/main-menu.html
+++ b/client/salix/src/components/main-menu/main-menu.html
@@ -1,4 +1,8 @@
+
+
{{currentUserName}}
+
{
+ this.$.currentUserName = json.data;
+ });
+ }
+
onLogoutClick() {
this.$window.location = '/logout';
}
onChangeLangClick(lang) {
this.$translate.use(lang);
}
+ $onInit() {
+ this.getCurrentUserName();
+ }
}
-MainMenu.$inject = ['$translate', '$window', 'modulesFactory'];
+MainMenu.$inject = ['$translate', '$scope', '$http', '$window', 'modulesFactory'];
ngModule.component('vnMainMenu', {
template: require('./main-menu.html'),
diff --git a/client/salix/src/components/main-menu/style.scss b/client/salix/src/components/main-menu/style.scss
index bf50a606b..405a0517b 100644
--- a/client/salix/src/components/main-menu/style.scss
+++ b/client/salix/src/components/main-menu/style.scss
@@ -1,4 +1,8 @@
vn-main-menu {
+ #user {
+ display: inline-block;
+ padding-right: 0.2em;
+ }
& > div > vn-icon {
font-size: 2.2em;
cursor: pointer;
diff --git a/services/loopback/common/models/account.js b/services/loopback/common/models/account.js
index d58ad5f60..7a3e2a94a 100644
--- a/services/loopback/common/models/account.js
+++ b/services/loopback/common/models/account.js
@@ -13,4 +13,33 @@ module.exports = function(Self) {
}
next();
});
+
+ Self.remoteMethod('getCurrentUserName', {
+ description: 'Gets the current user name',
+ accepts: [
+ {
+ arg: 'context',
+ type: 'object',
+ http: function(ctx) {
+ return ctx;
+ }
+ }
+ ],
+ returns: {
+ type: 'string',
+ root: true
+ },
+ http: {
+ verb: 'GET',
+ path: '/getCurrentUserName'
+ }
+ });
+
+ Self.getCurrentUserName = async function(ctx) {
+ let filter = {fields: ['name']};
+ let userId = ctx.req.accessToken.userId;
+ let account = await Self.findById(userId, filter);
+
+ return account.name;
+ };
};
diff --git a/services/loopback/server/middleware/current-user.js b/services/loopback/server/middleware/current-user.js
index e19cb2778..253d09f83 100644
--- a/services/loopback/server/middleware/current-user.js
+++ b/services/loopback/server/middleware/current-user.js
@@ -9,7 +9,6 @@ module.exports = function(options) {
if (loopbackContext) {
loopbackContext.set('currentUser', req.accessToken.userId);
}
-
next();
};
};