diff --git a/src/connection/enterprise.js b/src/connection/enterprise.js index 68db4819e..1fa2ff22d 100644 --- a/src/connection/enterprise.js +++ b/src/connection/enterprise.js @@ -133,7 +133,9 @@ 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/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 b27da5bd3..079779e27 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 === false ? false : true })); 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)