From ee45eabc6b57d4e4c4d86ce2c9953a10600988b1 Mon Sep 17 00:00:00 2001 From: German Lena Date: Mon, 19 Dec 2016 15:51:56 -0300 Subject: [PATCH 1/2] is not implemented #713 --- src/connection/enterprise.js | 3 ++- src/core/index.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/connection/enterprise.js b/src/connection/enterprise.js index 68db4819e..dd7ab296d 100644 --- a/src/connection/enterprise.js +++ b/src/connection/enterprise.js @@ -133,7 +133,8 @@ export function isHRDDomain(m, email) { export function toggleHRD(m, email) { if (email) { - m = setUsername(m, emailLocalPart(email), "username", false); + const username = l.defaultADUsernameFromEmailPrefix(m) ? emailLocalPart(email) : email; + m = setUsername(m, username, "username", false); m = tset(m, "hrdEmail", email); } else { m = tremove(m, "hrdEmail"); diff --git a/src/core/index.js b/src/core/index.js index b27da5bd3..f1ec1a87c 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -36,7 +36,8 @@ export function setup(id, clientID, domain, options, hookRunner, emitEventFn) { useTenantInfo: options.__useTenantInfo || false, hashCleanup: options.hashCleanup === false ? false : true, allowedConnections: Immutable.fromJS(options.allowedConnections || []), - ui: extractUIOptions(id, options) + ui: extractUIOptions(id, options), + defaultADUsernameFromEmailPrefix: !!options.defaultADUsernameFromEmailPrefix })); m = i18n.initI18n(m); @@ -323,6 +324,10 @@ export function loggedIn(m) { return tget(m, "loggedIn", false); } +export function defaultADUsernameFromEmailPrefix(m) { + return get(m, "defaultADUsernameFromEmailPrefix", true); +} + export function warn(x, str) { const shouldOutput = Map.isMap(x) ? !ui.disableWarnings(x) From b819612c50cfd3335e562d9af6859740b589829e Mon Sep 17 00:00:00 2001 From: German Lena Date: Mon, 19 Dec 2016 16:55:55 -0300 Subject: [PATCH 2/2] [v10] Enterprise connections don't strip domain from email #543 --- src/connection/enterprise.js | 1 + src/connection/enterprise/actions.js | 8 ++++++-- src/connection/enterprise/hrd_screen.jsx | 4 ++-- src/core/index.js | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/connection/enterprise.js b/src/connection/enterprise.js index dd7ab296d..1fa2ff22d 100644 --- a/src/connection/enterprise.js +++ b/src/connection/enterprise.js @@ -134,6 +134,7 @@ export function isHRDDomain(m, email) { export function toggleHRD(m, email) { if (email) { const username = l.defaultADUsernameFromEmailPrefix(m) ? emailLocalPart(email) : email; + m = setUsername(m, username, "username", false); m = tset(m, "hrdEmail", email); } else { diff --git a/src/connection/enterprise/actions.js b/src/connection/enterprise/actions.js index c7668055d..a4309e1e1 100644 --- a/src/connection/enterprise/actions.js +++ b/src/connection/enterprise/actions.js @@ -6,7 +6,9 @@ import { toggleHRD } from '../enterprise'; import { getFieldValue, hideInvalidFields } from '../../field/index'; +import { emailLocalPart } from '../../field/email'; import { logIn as coreLogIn } from '../../core/actions'; +import * as l from '../../core/index'; // TODO: enterprise connections should not depend on database // connections. However, we now allow a username input to contain also @@ -49,8 +51,10 @@ function logInActiveFlow(id) { ? "username" : "email"; - const username = getFieldValue(m, usernameField); - const connection = enterpriseActiveFlowConnection(m); + const originalUsername = getFieldValue(m, usernameField); + const connection = enterpriseActiveFlowConnection(m); + + const username = l.defaultADUsernameFromEmailPrefix(m) ? emailLocalPart(originalUsername) : originalUsername; coreLogIn(id, ["password", usernameField], { connection: connection ? connection.get("name") : null, diff --git a/src/connection/enterprise/hrd_screen.jsx b/src/connection/enterprise/hrd_screen.jsx index 64e622ddf..96a16e524 100644 --- a/src/connection/enterprise/hrd_screen.jsx +++ b/src/connection/enterprise/hrd_screen.jsx @@ -10,9 +10,9 @@ const Component = ({i18n, model}) => { const domain = enterpriseDomain(model); var headerText; - + if (domain != null) { - headerText = i18n.html("enterpriseActiveLoginInstructions", domain); + headerText = i18n.html("enterpriseActiveLoginInstructions", domain); } else { headerText = i18n.html("enterpriseLoginIntructions"); } diff --git a/src/core/index.js b/src/core/index.js index f1ec1a87c..079779e27 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -37,7 +37,7 @@ export function setup(id, clientID, domain, options, hookRunner, emitEventFn) { hashCleanup: options.hashCleanup === false ? false : true, allowedConnections: Immutable.fromJS(options.allowedConnections || []), ui: extractUIOptions(id, options), - defaultADUsernameFromEmailPrefix: !!options.defaultADUsernameFromEmailPrefix + defaultADUsernameFromEmailPrefix: options.defaultADUsernameFromEmailPrefix === false ? false : true })); m = i18n.initI18n(m);