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

Rename methods based on authN and authZ type #280

Merged
merged 3 commits into from
Jan 3, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Parameters:

### API

- **login(options)**: Redirects to the hosted login page to initialize an authN/authZ transaction.
- **authorize(options)**: Redirects to the hosted login page to initialize an authN/authZ transaction.

```js
auth0.login({
auth0.authorize({
audience: 'url:auth:some-audience',
scope: 'read:something write:otherthing',
responseType: 'token',
Expand Down
8 changes: 4 additions & 4 deletions src/web-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ WebAuth.prototype.signup = function (options, cb) {
/**
* Redirects to the hosted login page (`/authorize`) in order to initialize a new authN/authZ transaction
*
* @method login
* @method authorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#get--authorize_db
* @param {Function} cb
*/
WebAuth.prototype.login = function (options) {
WebAuth.prototype.authorize = function (options) {
var params = objectHelper.merge(this.baseOptions, [
'clientID',
'responseType',
Expand All @@ -297,11 +297,11 @@ WebAuth.prototype.login = function (options) {
* Signs up a new user, automatically logs the user in after the signup and returns the user token.
* The login will be done using /oauth/token with password-realm grant type.
*
* @method signupAndLogin
* @method signupAndAuthorize
* @param {Object} options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* @param {Function} cb
*/
WebAuth.prototype.signupAndLogin = function (options, cb) {
WebAuth.prototype.signupAndAuthorize = function (options, cb) {
var _this = this;

return this.client.dbConnection.signup(objectHelper.blacklist(options, ['popupHandler']),
Expand Down
10 changes: 5 additions & 5 deletions src/web-auth/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ Popup.prototype.authorize = function (options, cb) {
/**
* Initializes the legacy Lock login flow in a popup
*
* @method login
* @method loginWithCredentials
* @param {Object} options
* @param {Function} cb
* @deprecated `webauth.popup.login` will be soon deprecated, use `webauth.client.login` instead.
* @deprecated `webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.
*/
Popup.prototype.login = function (options, cb) {
Popup.prototype.loginWithCredentials = function (options, cb) {
var params;
var popup;
var url;
var relayUrl;

this.warn.warning('`webauth.popup.login` will be soon deprecated, use `webauth.client.login` instead.');
this.warn.warning('`webauth.popup.loginWithCredentials` will be soon deprecated, use `webauth.client.login` instead.');

/* eslint-disable */
assert.check(options, { type: 'object', message: 'options parameter is not valid' }, {
Expand Down Expand Up @@ -179,7 +179,7 @@ Popup.prototype.signupAndLogin = function (options, cb) {
}
return cb(err);
}
_this.login(options, cb);
_this.loginWithCredentials(options, cb);
});
};

Expand Down
10 changes: 5 additions & 5 deletions src/web-auth/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ function Redirect(client, options) {
/**
* Initializes the legacy Lock login flow in redirect mode
*
* @method login
* @method loginWithCredentials
* @param {Object} options
* @param {Function} cb
* @deprecated `webauth.redirect.login` will be soon deprecated, use `webauth.login` instead.
* @deprecated `webauth.redirect.loginWithCredentials` will be soon deprecated, use `webauth.login` instead.
*/
Redirect.prototype.login = function (options, cb) {
Redirect.prototype.loginWithCredentials = function (options, cb) {
var usernamePassword;

var params = objectHelper.merge(this.baseOptions, [
Expand All @@ -35,7 +35,7 @@ Redirect.prototype.login = function (options, cb) {
'audience'
]).with(options);

this.warn.warning('`webauth.redirect.login` will be soon deprecated, use `webauth.login` instead.');
this.warn.warning('`webauth.redirect.loginWithCredentials` will be soon deprecated, use `webauth.login` instead.');

assert.check(params, { type: 'object', message: 'options parameter is not valid' }, {
responseType: { type: 'string', message: 'responseType option is required' }
Expand Down Expand Up @@ -65,7 +65,7 @@ Redirect.prototype.signupAndLogin = function (options, cb) {
if (err) {
return cb(err);
}
return _this.login(options, cb);
return _this.loginWithCredentials(options, cb);
});
};

Expand Down
2 changes: 1 addition & 1 deletion test/web-auth/popup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('auth0.WebAuth.popup', function () {
});
});

this.auth0.popup.login({
this.auth0.popup.loginWithCredentials({
connection: 'the_connection',
nonce: '123',
state: '456',
Expand Down
8 changes: 4 additions & 4 deletions test/web-auth/redirect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('auth0.WebAuth.redirect', function () {

var auth0 = new WebAuth(configuration);

auth0.redirect.login({
auth0.redirect.loginWithCredentials({
connection: 'tests',
username: 'me@example.com',
password: '1234',
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('auth0.WebAuth.redirect', function () {

var auth0 = new WebAuth(configuration);

auth0.redirect.login({
auth0.redirect.loginWithCredentials({
connection: 'tests',
email: 'me@example.com',
password: '1234',
Expand Down Expand Up @@ -560,14 +560,14 @@ describe('auth0.WebAuth.redirect', function () {
it('should check that responseType is present', function() {
var _this = this;
expect(function() {
_this.auth0.login({ connection: 'facebook' })
_this.auth0.authorize({ connection: 'facebook' })
}).to.throwException(function (e) {
expect(e.message).to.be('responseType option is required');
});
})

it('should redirect to authorize', function () {
this.auth0.login({responseType: 'code', connection: 'facebook', state: '1234'})
this.auth0.authorize({responseType: 'code', connection: 'facebook', state: '1234'})
expect(global.window.location).to.be('https://me.auth0.com/authorize?connection=facebook&client_id=...&response_type=code&redirect_uri=http%3A%2F%2Fpage.com%2Fcallback&state=1234');
});

Expand Down
6 changes: 3 additions & 3 deletions test/web-auth/web-auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ describe('auth0.WebAuth', function () {
});

expect(function() {
webAuth.login({ connection: 'facebook' })
webAuth.authorize({ connection: 'facebook' })
}).to.throwException(function (e) {
expect(e.message).to.be('responseType option is required');
});
Expand Down Expand Up @@ -649,7 +649,7 @@ describe('auth0.WebAuth', function () {
throw new Error('Invalid url in request post stub');
});

this.auth0.signupAndLogin({
this.auth0.signupAndAuthorize({
connection: 'the_connection',
email: 'me@example.com',
password: '123456',
Expand Down Expand Up @@ -688,7 +688,7 @@ describe('auth0.WebAuth', function () {
});
});

this.auth0.signupAndLogin({
this.auth0.signupAndAuthorize({
connection: 'the_connection',
email: 'me@example.com',
password: '123456',
Expand Down