-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from auth0/fix-passwordless
Fix passwordless
- Loading branch information
Showing
7 changed files
with
87 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,18 @@ <h2>Login with database connection:</h2> | |
<input type="button" class="login-db" value="login" /> | ||
</div> | ||
|
||
<div> | ||
<h2>Login with passwordless connection:</h2> | ||
<div> | ||
<input class="passwordless-login-username" value="" /> | ||
<input type="button" class="passwordless-login-db" value="login" /> | ||
</div> | ||
<div> | ||
<input class="passwordless-login-code" value="Code" /> | ||
<input type="button" class="passwordless-login-verify" value="verify" /> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<h2>Login with database connection (popup):</h2> | ||
<input class="popup-login-username" value="[email protected]" /> | ||
|
@@ -167,11 +179,18 @@ <h2>Console:</h2> | |
}); | ||
|
||
var webAuth = new auth0.WebAuth({ | ||
domain: 'auth0-tests-auth0js.auth0.com', | ||
domain: 'brucke.auth0.com', | ||
redirectUri: 'http://localhost:3000/example', | ||
clientID: '3GGMIEuBPZ28lb6NBDNARaEZisqFakAs', | ||
audience: 'https://auth0-tests-auth0js.auth0.com/userinfo', | ||
responseType: 'token id_token' | ||
clientID: 'k5u3o2fiAA8XweXEEX604KCwCjzjtMU6', | ||
audience: 'https://brucke.auth0.com/userinfo', | ||
responseType: 'token' | ||
}); | ||
|
||
var webAuthPasswordless = new auth0.WebAuth({ | ||
domain: 'brucke.auth0.com', | ||
redirectUri: 'http://localhost:3000/example', | ||
clientID: 'k5u3o2fiAA8XweXEEX604KCwCjzjtMU6', | ||
responseType: 'token' | ||
}); | ||
|
||
webAuth.parseHash(function(err, data) { | ||
|
@@ -213,6 +232,24 @@ <h2>Console:</h2> | |
}, htmlConsole.dumpCallback.bind(htmlConsole)); | ||
}); | ||
|
||
$('.passwordless-login-verify').click(function (e) { | ||
e.preventDefault(); | ||
webAuthPasswordless.passwordlessVerify({ | ||
connection: 'email', | ||
email: $('.passwordless-login-username').val(), | ||
verificationCode: $('.passwordless-login-code').val() | ||
}, htmlConsole.dumpCallback.bind(htmlConsole)); | ||
}); | ||
|
||
$('.passwordless-login-db').click(function (e) { | ||
e.preventDefault(); | ||
webAuthPasswordless.passwordlessStart({ | ||
connection: 'email', | ||
email: $('.passwordless-login-username').val(), | ||
send: 'code' | ||
}, htmlConsole.dumpCallback.bind(htmlConsole)); | ||
}); | ||
|
||
var popupHandler; | ||
|
||
$('.popup-login-db-preload').click(function (e) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,50 +37,32 @@ describe('auth0.authentication', function () { | |
}); | ||
}); | ||
|
||
it('should check that options.type is passed', function () { | ||
it('should check that options.send is passed', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.start({ connection: 'bla' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('type option is required'); | ||
expect(e.message).to.be('send option is required'); | ||
}); | ||
}); | ||
|
||
it('should check that options.type is valid', function () { | ||
it('should check that options.send is valid', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.start({ connection: 'bla', type: 'blabla' }); | ||
_this.auth0.passwordless.start({ connection: 'bla', send: 'blabla' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('type is not valid ([email,sms])'); | ||
expect(e.message).to.be('send is not valid ([link, code])'); | ||
}); | ||
}); | ||
|
||
it('should check that cb is valid', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.start({ connection: 'bla', type: 'email', email: '[email protected]' }); | ||
_this.auth0.passwordless.start({ connection: 'bla', send: 'code', email: '[email protected]' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('cb parameter is not valid'); | ||
}); | ||
}); | ||
|
||
it('should check that email is sent', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.start({ connection: 'bla', type: 'email' }, function () {}); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('email option is required'); | ||
}); | ||
}); | ||
|
||
it('should check that phoneNumber is sent', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.start({ connection: 'bla', type: 'sms' }, function () {}); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('phoneNumber option is required'); | ||
}); | ||
}); | ||
}); | ||
|
||
context('passwordless verify options', function () { | ||
|
@@ -117,14 +99,14 @@ describe('auth0.authentication', function () { | |
expect(function () { | ||
_this.auth0.passwordless.verify({ connection: 'bla' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('type option is required'); | ||
expect(e.message).to.be('verificationCode option is required'); | ||
}); | ||
}); | ||
|
||
it('should check that options.verificationCode is passed', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.verify({ connection: 'bla', type: 'email' }); | ||
_this.auth0.passwordless.verify({ connection: 'bla', send: 'code' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('verificationCode option is required'); | ||
}); | ||
|
@@ -133,16 +115,16 @@ describe('auth0.authentication', function () { | |
it('should check that options.type is valid', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.verify({ connection: 'bla', type: 'blabla', verificationCode: 'asdfasd' }); | ||
_this.auth0.passwordless.verify({ connection: 'bla', verificationCode: 'asdfasd' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('type is not valid ([email,sms])'); | ||
expect(e.message).to.be('phoneNumber option is required'); | ||
}); | ||
}); | ||
|
||
it('should check that cb is valid', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.verify({ connection: 'bla', type: 'email', verificationCode: 'asdfasd', email: '[email protected]' }); | ||
_this.auth0.passwordless.verify({ connection: 'bla', send: 'link', verificationCode: 'asdfasd', email: '[email protected]' }); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('cb parameter is not valid'); | ||
}); | ||
|
@@ -151,16 +133,16 @@ describe('auth0.authentication', function () { | |
it('should check that email is sent', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.verify({ connection: 'bla', type: 'email', verificationCode: 'asdfasd' }, function () {}); | ||
_this.auth0.passwordless.verify({ connection: 'bla', send: 'code', verificationCode: 'asdfasd' }, function () {}); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('email option is required'); | ||
expect(e.message).to.be('phoneNumber option is required'); | ||
}); | ||
}); | ||
|
||
it('should check that phoneNumber is sent', function () { | ||
var _this = this; | ||
expect(function () { | ||
_this.auth0.passwordless.verify({ connection: 'bla', type: 'sms', verificationCode: 'asdfasd' }, function () {}); | ||
_this.auth0.passwordless.verify({ connection: 'bla', send: 'code', verificationCode: 'asdfasd' }, function () {}); | ||
}).to.throwException(function (e) { | ||
expect(e.message).to.be('phoneNumber option is required'); | ||
}); | ||
|
@@ -190,6 +172,7 @@ describe('auth0.authentication', function () { | |
client_id: '...', | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
send: 'link', | ||
authParams: { | ||
redirect_uri: 'http://page.com/callback', | ||
response_type: 'code' | ||
|
@@ -209,7 +192,7 @@ describe('auth0.authentication', function () { | |
this.auth0.passwordless.start({ | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
type: 'email' | ||
send: 'link' | ||
}, function (err, data) { | ||
expect(err).to.be(null); | ||
expect(data).to.eql({ | ||
|
@@ -227,6 +210,7 @@ describe('auth0.authentication', function () { | |
client_id: '...', | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
send: 'code', | ||
authParams: { | ||
scope: 'openid email', | ||
redirect_uri: 'http://page.com/callback', | ||
|
@@ -247,7 +231,7 @@ describe('auth0.authentication', function () { | |
this.auth0.passwordless.start({ | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
type: 'email', | ||
send: 'code', | ||
scope: 'openid email' | ||
}, function (err, data) { | ||
expect(err).to.be(null); | ||
|
@@ -297,7 +281,6 @@ describe('auth0.authentication', function () { | |
this.auth0.passwordless.verify({ | ||
connection: 'the_connection', | ||
phoneNumber: '123456', | ||
type: 'sms', | ||
verificationCode: 'abc' | ||
}, function (err, data) { | ||
expect(err).to.be(null); | ||
|
@@ -331,7 +314,6 @@ describe('auth0.authentication', function () { | |
this.auth0.passwordless.verify({ | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
type: 'email', | ||
verificationCode: 'abc' | ||
}, function (err, data) { | ||
expect(err).to.be(null); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,6 @@ describe('auth0.WebAuth.popup', function () { | |
}); | ||
|
||
this.auth0.popup.passwordlessVerify({ | ||
type: 'sms', | ||
connection: 'the_connection', | ||
phoneNumber: '+5491178786555', | ||
verificationCode: '123' | ||
|
@@ -298,7 +297,6 @@ describe('auth0.WebAuth.popup', function () { | |
}); | ||
|
||
this.auth0.popup.passwordlessVerify({ | ||
type: 'email', | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
verificationCode: '123' | ||
|
@@ -339,7 +337,6 @@ describe('auth0.WebAuth.popup', function () { | |
}); | ||
|
||
this.auth0.popup.passwordlessVerify({ | ||
type: 'sms', | ||
connection: 'the_connection', | ||
phoneNumber: '+5491178786555', | ||
verificationCode: '123' | ||
|
Oops, something went wrong.