Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only set prefill values when client is initialized #855

Merged
merged 3 commits into from
Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ 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 === false ? false : true
defaultADUsernameFromEmailPrefix: options.defaultADUsernameFromEmailPrefix === false ? false : true,
prefill: options.prefill || {}
}));

m = i18n.initI18n(m);

return m;
}

Expand Down Expand Up @@ -365,6 +366,10 @@ export function defaultADUsernameFromEmailPrefix(m) {
return get(m, "defaultADUsernameFromEmailPrefix", true);
}

export function prefill(m) {
return get(m, "prefill", {});
}

export function warn(x, str) {
const shouldOutput = Map.isMap(x)
? !ui.disableWarnings(x)
Expand Down
15 changes: 10 additions & 5 deletions src/engine/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ function validateAllowedConnections(m) {
return m;
}

const setPrefill = m => {
const { email, username } = l.prefill(m).toJS();
if (typeof email === "string") m = setEmail(m, email);
if (typeof username === "string") m = setUsername(m, username, "username", false);
return m;
}

class Classic {

static SCREENS = {
Expand All @@ -111,15 +118,13 @@ class Classic {
model = initDatabase(model, options);
model = initEnterprise(model, options);

const { email, username } = options.prefill || {};
if (typeof email === "string") model = setEmail(model, email);
if (typeof username === "string") model = setUsername(model, username, "username", false);

return model;
}

didReceiveClientSettings(m) {
return validateAllowedConnections(m);
m = validateAllowedConnections(m);
m = setPrefill(m);
return m;
}

willShow(m, opts) {
Expand Down
1 change: 1 addition & 0 deletions support/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
};

const lock = new Auth0Lock(cid, domain, options);
window.lock = lock;

lock.on("authenticated", function(authResult) {
console.log(authResult);
Expand Down