Skip to content

Commit

Permalink
Merge pull request #381 from auth0/fixed-email-password-popup-stuck
Browse files Browse the repository at this point in the history
Pass to popup the needed params for auth
  • Loading branch information
luisrudge authored Mar 9, 2017
2 parents 5e5f423 + 2979ad2 commit 82e5de1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/web-auth/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,14 @@ Popup.prototype.loginWithCredentials = function (options, cb) {

params = objectHelper.pick(options, ['clientID', 'domain']);
params.options = objectHelper.toSnakeCase(
objectHelper.blacklist(options, ['clientID', 'domain'])
objectHelper.pick(options, ['password', 'connection', 'state', 'scope', '_csrf', 'device'])
);
params.options.username = options.username || options.email;

url = urljoin(this.baseOptions.rootUrl, 'sso_dbconnection_popup', options.clientID);
relayUrl = urljoin(this.baseOptions.rootUrl, 'relay.html');

return popup.load(url, relayUrl, params, responseHandler(cb));
return popup.load(url, relayUrl, { params: params }, responseHandler(cb));
};

/**
Expand Down
38 changes: 21 additions & 17 deletions test/web-auth/popup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ describe('auth0.WebAuth.popup', function () {
stub(PopupHandler.prototype, 'load', function(url, relayUrl, options, cb) {
expect(url).to.be('https://me.auth0.com/sso_dbconnection_popup/...');
expect(relayUrl).to.be('https://me.auth0.com/relay.html');
expect(options).to.eql({ clientID: '...',
domain: 'me.auth0.com',
options:{
connection: 'the_connection',
nonce: '123',
state: '456',
username: 'theUsername',
password: 'thepassword',
scope: 'openid'
expect(options).to.eql({
params: {
clientID: '...',
domain: 'me.auth0.com',
options:{
connection: 'the_connection',
state: '456',
username: 'theUsername',
password: 'thepassword',
scope: 'openid'
}
}
});

Expand All @@ -156,7 +158,6 @@ describe('auth0.WebAuth.popup', function () {

this.auth0.popup.loginWithCredentials({
connection: 'the_connection',
nonce: '123',
state: '456',
username: 'theUsername',
password: 'thepassword',
Expand Down Expand Up @@ -385,13 +386,16 @@ describe('auth0.WebAuth.popup', function () {
stub(PopupHandler.prototype, 'load', function(url, relayUrl, options, cb) {
expect(url).to.be('https://me.auth0.com/sso_dbconnection_popup/...');
expect(relayUrl).to.be('https://me.auth0.com/relay.html');
expect(options).to.eql({ clientID: '...',
domain: 'me.auth0.com',
options:{
connection: 'the_connection',
email: 'me@example.com',
password: '123456',
scope: 'openid'
expect(options).to.eql({
params: {
clientID: '...',
domain: 'me.auth0.com',
options:{
connection: 'the_connection',
username: 'me@example.com',
password: '123456',
scope: 'openid'
}
}
});

Expand Down

0 comments on commit 82e5de1

Please sign in to comment.