diff --git a/app/ldap/server/loginHandler.js b/app/ldap/server/loginHandler.js index d8ec65ce7a88..c563ea950c99 100644 --- a/app/ldap/server/loginHandler.js +++ b/app/ldap/server/loginHandler.js @@ -74,11 +74,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) { } if (ldapUser === undefined) { - if (settings.get('LDAP_Login_Fallback') === true) { - return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass); - } - - throw new Meteor.Error('LDAP-login-error', `LDAP Authentication failed with provided username [${ loginRequest.username }]`); + return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass); } // Look to see if user already exists @@ -120,7 +116,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) { if (user) { if (user.ldap !== true && settings.get('LDAP_Merge_Existing_Users') !== true) { logger.info('User exists without "ldap: true"'); - throw new Meteor.Error('LDAP-login-error', `LDAP Authentication succeded, but there's already an existing user with provided username [${ username }] in Mongo.`); + throw new Meteor.Error('LDAP-login-error', `LDAP Authentication succeeded, but there's already an existing user with provided username [${ username }] in Mongo.`); } logger.info('Logging user'); @@ -156,3 +152,19 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) { return result; }); + +callbacks.add('beforeValidateLogin', (login) => { + if (!login.allowed) { + return login; + } + + if (login.type === 'ldap') { + return login; + } + + if (login.user.services && login.user.services.ldap && login.user.services.ldap.id) { + login.allowed = !!settings.get('LDAP_Login_Fallback'); + } + + return login; +}); diff --git a/app/ldap/server/settings.js b/app/ldap/server/settings.js index 598537a8056e..c07c0e1e7fb0 100644 --- a/app/ldap/server/settings.js +++ b/app/ldap/server/settings.js @@ -33,7 +33,7 @@ settings.addGroup('LDAP', function() { ]; this.add('LDAP_Enable', false, { type: 'boolean', public: true }); - this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery }); + this.add('LDAP_Login_Fallback', false, { type: 'boolean', enableQuery: null }); this.add('LDAP_Find_User_After_Login', true, { type: 'boolean', enableQuery }); this.add('LDAP_Host', '', { type: 'string', enableQuery }); this.add('LDAP_Port', '389', { type: 'string', enableQuery }); diff --git a/app/lib/server/functions/getAvatarSuggestionForUser.js b/app/lib/server/functions/getAvatarSuggestionForUser.js index f2bb8cd47306..66c58531dd10 100644 --- a/app/lib/server/functions/getAvatarSuggestionForUser.js +++ b/app/lib/server/functions/getAvatarSuggestionForUser.js @@ -34,10 +34,11 @@ const avatarProviders = { }, linkedin(user) { - if (user.services && user.services.linkedin && user.services.linkedin.pictureUrl && settings.get('Accounts_OAuth_Linkedin')) { + if (user.services && user.services.linkedin && user.services.linkedin.profilePicture && user.services.linkedin.profilePicture.identifiersUrl && user.services.linkedin.profilePicture.identifiersUrl.length > 0 && settings.get('Accounts_OAuth_Linkedin')) { + const total = user.services.linkedin.profilePicture.identifiersUrl.length; return { service: 'linkedin', - url: user.services.linkedin.pictureUrl, + url: user.services.linkedin.profilePicture.identifiersUrl[total - 1], }; } }, diff --git a/app/livechat/client/stylesheets/livechat.less b/app/livechat/client/stylesheets/livechat.less index c79cba89c444..00fbbed79423 100644 --- a/app/livechat/client/stylesheets/livechat.less +++ b/app/livechat/client/stylesheets/livechat.less @@ -13,8 +13,8 @@ .trigger-option, .trigger-value { - float: left; display: inline-block; + float: left; } .trigger-option { @@ -26,29 +26,37 @@ .trigger-value { width: 70%; - textarea, input, select { + textarea, + input, + select { display: block !important; + width: auto !important; - margin-bottom: 4px; min-width: 50%; + margin-bottom: 4px; } } .livechat-code { width: 90%; max-width: 750px; + text-align: right; textarea { - text-align: left; + display: block; + width: 100%; height: 200px; + + margin-bottom: 1rem; + + text-align: left; + background-color: #efefef; + font-family: courier; font-size: 12px; - display: block; - - margin-bottom: 1rem; } } @@ -69,14 +77,18 @@ li { display: inline-block; - background-color: #dddddd; - border-radius: 10px; - padding: 2px 8px 2px 2px; + margin: 1px 0; + padding: 2px 8px 2px 2px; + cursor: pointer; + border-radius: 10px; + background-color: #dddddd; + .icon-plus-circled { opacity: 0.5; + font-size: 0.8rem; } } @@ -85,8 +97,9 @@ .agent-info { input[type='text'] { width: auto; - line-height: 24px; height: 24px; + + line-height: 24px; } } @@ -97,24 +110,28 @@ .visitor-navigation, .visitor-custom-fields { .visitor-scroll { - height: 130px; overflow-y: auto; - border: 1px solid #e7e7e7; - border-radius: 4px; - padding: 4px; + + height: 130px; margin-top: 4px; margin-bottom: 20px; + padding: 4px; + + border: 1px solid #e7e7e7; + border-radius: 4px; ul { li { white-space: nowrap; a { - text-overflow: ellipsis; display: block; overflow: hidden; - color: @secondary-font-color; + text-decoration: underline; + text-overflow: ellipsis; + + color: @secondary-font-color; &:hover { text-decoration: none; @@ -130,39 +147,46 @@ } .livechat-status { + color: #9d9fa3; + font-size: 20px; line-height: 18px; - color: #9d9fa3; } .external-message { - padding: 10px; position: relative; + padding: 10px; + &::after { - content: " "; position: absolute; - border-bottom: 1px solid #cccccc; - left: 10px; right: 10px; bottom: 0; + left: 10px; + + content: " "; + + border-bottom: 1px solid #cccccc; } } .user-view { li { color: @secondary-font-color; - line-height: 18px; + font-size: 12px; font-weight: 300; + line-height: 18px; } nav.centered-buttons { - text-align: center; margin-bottom: 1em; + text-align: center; + button { display: inline-block; + width: auto; } } @@ -178,8 +202,9 @@ .visitor-edit { h3 { - font-size: 24px; margin-bottom: 8px; + + font-size: 24px; line-height: 22px; } } @@ -192,27 +217,31 @@ .lc-analytics-table { display: flex; - flex-flow: column; - // width: 100%; - min-height: 300px; + height: ~"calc(100% - 280px)"; height: ~"-webkit-calc-height(100% - 280px)"; + + min-height: 300px; + flex-flow: column; } .lc-analytics-flex-container { position: relative; + display: flex; - flex-flow: row; + height: 100%; - // align-content: stretch; + flex-flow: row; } .lc-analytics-chart-col { position: relative; + flex: 66.66666%; + max-width: 66.66666%; - padding-right: 2px; max-height: 100%; + padding-right: 2px; } .lc-chart-ov-content { @@ -221,137 +250,141 @@ .lc-analytics-chart-ov-col { position: relative; + flex: 33.33333%; + max-width: 33.33333%; - // overflow: scroll; - padding-left: 2px; height: 100%; + + padding-left: 2px; } .lc-chart-section { position: relative; + height: 100%; max-height: 100%; } .lc-chart-section-content { position: relative; - width: 100%; - height: 100%; - // max-height: 100%; + display: flex; flex-direction: column; -} -.lc-chart-options { - // flex: 1; + width: 100%; + height: 100%; } .border-component-td { - padding: 0.5rem; + padding: 0.5rem; } .lc-analytics-chart-container { - // flex-grow: 100%; - flex: auto; position: relative; - // height: inherit; + + flex: auto; } .lc-analytics-header { float: right; - & > .lc-date-picker-btn { - font-weight: inherit; - font-size: inherit; - color: #383838; - //line-height: 1; - padding-top: 23px; - } - - & > .lc-date-picker-btn { - // padding-top: 15px; - // padding-right: 25px; - // padding-left: 10px; - position: relative; - - .fade { - color: #9ea2a8; - } - } + + & > .lc-date-picker-btn { + position: relative; + + padding-top: 23px; + + color: #383838; + + font-size: inherit; + font-weight: inherit; + + .fade { + color: #9ea2a8; + } + } } .lc-analytics-overview { - display: flex; - flex-wrap: wrap; - margin-top: 10px; - margin-bottom: 10px; + display: flex; + + margin-top: 10px; + margin-bottom: 10px; + flex-wrap: wrap; justify-content: center; } .lc-analytics-ov-col { - min-height: 20px; - flex: 25%; //1; - max-width: 25%; + flex: 25%; - &.-full-width { - max-width: 100%; - } + max-width: 25%; + min-height: 20px; + + &.-full-width { + max-width: 100%; + } - &:not(:last-child) { - border-right: 1px solid #E9E9E9; - } + &:not(:last-child) { + border-right: 1px solid #e9e9e9; + } } .lc-analytics-ov-case { - width: 100%; - text-align: center; - margin-bottom: 20px; - user-select: text; - - &:first-child { - margin-top: 8px; - //border-bottom: 1px solid #E9E9E9; - } - - &.-standalone { - & > .title { - margin-top: 1px; + width: 100%; + margin-bottom: 20px; + + user-select: text; + text-align: center; + + &:first-child { + margin-top: 8px; + } + + &.-standalone { + & > .title { display: inline-block; - font-size: .875rem; - font-weight: 300; - text-transform: none; - // margin-bottom: 6px; - } - & > .value { - // margin-top: 1px; - font-size: 1.75rem; + + margin-top: 1px; + + text-transform: none; + + font-size: 0.875rem; + font-weight: 300; + } + + & > .value { margin-bottom: 6px; - } - } - & > .title { + font-size: 1.75rem; + } + } + + & > .title { + display: inline-block; + margin-top: 8px; + + text-transform: uppercase; + + color: #9ea2a8; + + font-size: 0.875rem; + font-weight: 300; + } + + & > .value { display: inline-block; - font-weight: 300; - font-size: 0.875rem; - color: #9ea2a8; - text-transform: uppercase; - //cursor: help; - } - - & > .value { - display: inline-block; - width: 100%; - } - - & > .value { - // margin-top: 8px; - font-weight: 400; - font-size: 1.75rem; - color: #383838; - line-height: 1; - text-transform: capitalize; - } + + width: 100%; + + text-transform: capitalize; + + color: #383838; + + font-size: 1.75rem; + font-weight: 400; + line-height: 1; + } } @media screen and (max-width: 925px) { @@ -359,6 +392,7 @@ & > .title { font-size: 0.5rem; } + & > .value { font-size: 1rem; } @@ -370,18 +404,20 @@ .lc-analytics-chart-col { flex: 100%; + max-width: 100%; - padding-right: 0px; max-height: 100%; + padding-right: 0; padding-bottom: 2px; } .lc-analytics-chart-ov-col { - padding-left: 0; flex: 100%; + max-width: 100%; max-height: 100%; padding-top: 2px; + padding-left: 0; } } @@ -390,6 +426,7 @@ & > .title { font-size: 0.875rem; } + & > .value { font-size: 1.75rem; } @@ -401,18 +438,20 @@ .lc-analytics-chart-col { flex: 66.66666%; + max-width: 66.66666%; - padding-right: 2px; max-height: 100%; + padding-right: 2px; padding-bottom: 0; } .lc-analytics-chart-ov-col { - padding-left: 2px; flex: 33.33333%; + max-width: 33.33333%; max-height: 100%; padding-top: 0; + padding-left: 2px; } } @@ -421,6 +460,7 @@ & > .title { font-size: 0.5rem; } + & > .value { font-size: 1rem; } @@ -432,55 +472,56 @@ .lc-analytics-chart-col { flex: 100%; + max-width: 100%; - padding-right: 0; max-height: 100%; + padding-right: 0; padding-bottom: 2px; } .lc-analytics-chart-ov-col { - padding-left: 0; flex: 100%; + max-width: 100%; max-height: 100%; padding-top: 2px; + padding-left: 0; } } .lc-monitoring-flex { display: flex; - flex-wrap: wrap; - margin-bottom: 2px !important; + margin-top: 2px !important; - // flex-direction: row; - // margin-top: 10px; - // margin-bottom: 10px; - // justify-content: center; - // padding: 0 4px; + margin-bottom: 2px !important; + flex-wrap: wrap; } .lc-monitoring-doughnut-chart { flex: 33.33333%; + max-width: 33.33333%; - padding: 2px 2px; + padding: 2px; } .lc-monitoring-line-chart { flex: 66.66666%; + max-width: 66.66666%; - padding: 2px 2px; + padding: 2px; & .lc-analytics-ov-col { - min-height: 20px; - flex: 33.3%; //1; + flex: 33.3%; + max-width: 33.3%; + min-height: 20px; &.-full-width { - max-width: 100%; + max-width: 100%; } &:not(:last-child) { - border-right: 1px solid #E9E9E9; + border-right: 1px solid #e9e9e9; } } @@ -491,8 +532,9 @@ .lc-monitoring-line-chart-full { flex: 66.66666%; + width: 100%; - padding: 2px 2px; + padding: 2px; } .lc-monitoring-chart-container { @@ -502,16 +544,19 @@ @media screen and (max-width: 925px) { .lc-monitoring-doughnut-chart { flex: 100%; + max-width: 100%; } .lc-monitoring-line-chart { flex: 100%; + max-width: 100%; } .lc-monitoring-line-chart-full { flex: 100%; + max-width: 100%; } } @@ -519,16 +564,19 @@ @media screen and (max-width: 800px) { .lc-monitoring-doughnut-chart { flex: 33.33333%; + max-width: 33.33333%; } .lc-monitoring-line-chart { flex: 66.66666%; + max-width: 66.66666%; } .lc-monitoring-line-chart-full { flex: 66.66666%; + width: 66.66666%; max-width: 100%; } @@ -537,16 +585,19 @@ @media screen and (max-width: 600px) { .lc-monitoring-doughnut-chart { flex: 100%; + max-width: 100%; } .lc-monitoring-line-chart { flex: 100%; + max-width: 100%; } .lc-monitoring-line-chart-full { flex: 100%; + max-width: 100%; } } @@ -561,6 +612,7 @@ .livechat-group-filters-buttons { flex: 0 0 auto; + margin-top: 26px; padding-left: 30px; @@ -581,4 +633,3 @@ .livechat-current-chats-add-filter-button { margin-top: 17px; } - diff --git a/app/models/server/models/LivechatDepartment.js b/app/models/server/models/LivechatDepartment.js index a57238234c40..652ba3dd72dc 100644 --- a/app/models/server/models/LivechatDepartment.js +++ b/app/models/server/models/LivechatDepartment.js @@ -9,6 +9,7 @@ export class LivechatDepartment extends Base { constructor(modelOrName) { super(modelOrName || 'livechat_department'); + this.tryEnsureIndex({ name: 1 }); this.tryEnsureIndex({ numAgents: 1, enabled: 1, diff --git a/package-lock.json b/package-lock.json index 0296bebbb172..bdb5822c96d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2694,6 +2694,11 @@ "uuid": "^3.2.1" }, "dependencies": { + "adm-zip": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.14.tgz", + "integrity": "sha512-/9aQCnQHF+0IiCl0qhXoK7qs//SwYE7zX8lsr/DNk1BRAHYxeLZPL4pguwK29gUEqasYQjqPtEpDRSWEkdHn9g==" + }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", @@ -2750,9 +2755,9 @@ "integrity": "sha512-cE8tq4MzfqJq3AiSKMQS6RWj5gYKDhnQZNP63q0ljtvcZDzGX/LL3zmACmrCwwjT4Y0XNp2CpPW9mNFtG20iNQ==" }, "@rocket.chat/livechat": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@rocket.chat/livechat/-/livechat-1.3.1.tgz", - "integrity": "sha512-FlnVnAVtGbb3Gko4iLarAhpdUQia6gkO55k47+A8lSTPM8ATNsJYVUZmequq/dOWz3ZLjJcIVyVu73Q5cpoEUw==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@rocket.chat/livechat/-/livechat-1.4.0.tgz", + "integrity": "sha512-jOUy49njPMW0ZmL9Gk6lRv4X0WTSS9N78iSzR/p3pSV4ivEQk1LRXCi6QLknZmxEXIpe6MTJgUY/ggsORfxrDQ==", "dev": true, "requires": { "@kossnocorp/desvg": "^0.2.0", @@ -6516,9 +6521,9 @@ } }, "acorn": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.7.tgz", - "integrity": "sha512-HNJNgE60C9eOTgn974Tlp3dpLZdUr+SoxxDwPaY9J/kDNOLQTkaDgwBUXAF4SSsrAwD9RpdxuHK/EbuF+W9Ahw==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==", "dev": true }, "acorn-dynamic-import": { @@ -12089,9 +12094,9 @@ } }, "date-fns": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.9.0.tgz", - "integrity": "sha512-khbFLu/MlzLjEzy9Gh8oY1hNt/Dvxw3J6Rbc28cVoYWQaC1S3YI4xwkF9ZWcjDLscbZlY9hISMr66RFzZagLsA==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.11.0.tgz", + "integrity": "sha512-8P1cDi8ebZyDxUyUprBXwidoEtiQAawYPGvpfb+Dg0G6JrQ+VozwOmm91xYC0vAv1+0VmLehEPb+isg4BGUFfA==", "dev": true }, "date-now": { @@ -16752,9 +16757,9 @@ } }, "i18n": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/i18n/-/i18n-0.8.5.tgz", - "integrity": "sha512-6UgLbhJGgn4XFeuZc/dDdrrri0ij24EK4hxv4Pbi5hloYAZ1B2+0eQchEryBFezLKYOHhVGV/5+H4i0oxng94w==", + "version": "0.8.6", + "resolved": "https://registry.npmjs.org/i18n/-/i18n-0.8.6.tgz", + "integrity": "sha512-aMsJq8i1XXrb+BBsgmJBwak9mr69zPEIAUPb6c5yw2G/O4k1Q52lBxL+agZdQDN/RGf1ylQzrCswsOOgIiC1FA==", "dev": true, "requires": { "debug": "*", @@ -16868,9 +16873,9 @@ "dev": true }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "supports-color": { @@ -19342,9 +19347,9 @@ } }, "make-plural": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/make-plural/-/make-plural-6.0.1.tgz", - "integrity": "sha512-h0uBNi4tpDkiWUyYKrJNj8Kif6q3Ba5zp/8jnfPy3pQE+4XcTj6h3eZM5SYVUyDNX9Zk69Isr/dx0I+78aJUaQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/make-plural/-/make-plural-6.1.0.tgz", + "integrity": "sha512-0ekbPHqxcdRcmjZ43TkRuejK5rXgMF1OjG4FVnVHgCvOcjrexaSX7a0dfAvqhOm1qWPgjYnXtmz3cHpHW5ZewA==", "dev": true }, "mamacro": { @@ -19744,9 +19749,9 @@ } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true, "optional": true } @@ -21118,9 +21123,9 @@ } }, "mustache": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.0.0.tgz", - "integrity": "sha512-FJgjyX/IVkbXBXYUwH+OYwQKqWpFPLaLVESd70yHjSDunwzV2hZOoTBvPf4KLoxesUzzyfTH6F784Uqd7Wm5yA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.0.1.tgz", + "integrity": "sha512-yL5VE97+OXn4+Er3THSmTdCFCtx5hHWzrolvH+JObZnUYwuaG7XV+Ch4fR2cIrcYI0tFHxS7iyFYl14bW8y2sA==", "dev": true }, "mute-stream": { diff --git a/package.json b/package.json index 4d0bb6be6017..c7a9d3512673 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "jslint": "eslint --ext .js,.jsx .", "tslint": "eslint --ext .ts,.tsx .", "eslint": "meteor npm run jslint && meteor npm run tslint", - "stylelint": "stylelint \"app/**/*.css\" \"client/**/*.css\"", + "stylelint": "stylelint \"app/**/*.css\" \"client/**/*.css\" \"app/**/*.less\" \"client/**/*.less\" \"ee/**/*.less\"", "deploy": "npm run build && pm2 startOrRestart pm2.json", "postinstall": "node .scripts/npm-postinstall.js", "testunit-watch": "mocha --watch --opts ./mocha.opts \"`node -e \"console.log(require('./package.json').mocha.tests.join(' '))\"`\"", @@ -63,7 +63,7 @@ "@babel/preset-react": "^7.0.0", "@octokit/rest": "^16.1.0", "@rocket.chat/eslint-config": "^0.3.0", - "@rocket.chat/livechat": "^1.3.1", + "@rocket.chat/livechat": "^1.4.0", "@settlin/spacebars-loader": "^1.0.7", "@storybook/addon-actions": "^5.2.8", "@storybook/addon-knobs": "^5.2.8", @@ -75,7 +75,7 @@ "@types/meteor": "^1.4.37", "@typescript-eslint/eslint-plugin": "^2.11.0", "@typescript-eslint/parser": "^2.11.0", - "acorn": "^6.0.7", + "acorn": "^6.4.1", "autoprefixer": "^9.6.1", "babel-eslint": "^10.0.3", "babel-loader": "^8.0.6", diff --git a/server/lib/accounts.js b/server/lib/accounts.js index 1083c9e03be0..95e3aa4bec90 100644 --- a/server/lib/accounts.js +++ b/server/lib/accounts.js @@ -98,6 +98,29 @@ Accounts.emailTemplates.enrollAccount.html = function(user = {}/* , url*/) { }); }; +const getLinkedInName = ({ firstName, lastName }) => { + const { preferredLocale, localized: firstNameLocalized } = firstName; + const { localized: lastNameLocalized } = lastName; + + // LinkedIn new format + if (preferredLocale && firstNameLocalized && preferredLocale.language && preferredLocale.country) { + const locale = `${ preferredLocale.language }_${ preferredLocale.country }`; + + if (firstNameLocalized[locale] && lastNameLocalized[locale]) { + return `${ firstNameLocalized[locale] } ${ lastNameLocalized[locale] }`; + } + if (firstNameLocalized[locale]) { + return firstNameLocalized[locale]; + } + } + + // LinkedIn old format + if (!lastName) { + return firstName; + } + return `${ firstName } ${ lastName }`; +}; + Accounts.onCreateUser(function(options, user = {}) { callbacks.run('beforeCreateUser', options, user); @@ -108,12 +131,9 @@ Accounts.onCreateUser(function(options, user = {}) { if (options.profile) { if (options.profile.name) { user.name = options.profile.name; - } else if (options.profile.firstName && options.profile.lastName) { - // LinkedIn format - user.name = `${ options.profile.firstName } ${ options.profile.lastName }`; } else if (options.profile.firstName) { // LinkedIn format - user.name = options.profile.firstName; + user.name = getLinkedInName(options.profile); } } }