Repository: auth0/auth0.js
Pull request #280 (2017-01-02 17:29:38)

Rename methods based on authN and authZ type

codecov-io: ## [Current coverage](https://codecov.io/gh/auth0/auth0.js/pull/280?src=pr) is 99.78% (diff: 100%)
> Merging [#280](https://codecov.io/gh/auth0/auth0.js/pull/280?src=pr) into [v8](https://codecov.io/gh/auth0/auth0.js/branch/v8?src=pr) will not change coverage

```diff
@@                 v8       #280   diff @@
==========================================
  Files            30         30          
  Lines           949        949          
  Methods         166        166          
  Messages          0          0          
  Branches        137        137          
==========================================
  Hits            947        947          
  Misses            2          2          
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last update [3085e77...4008201](https://codecov.io/gh/auth0/auth0.js/compare/3085e778359bddd60c54241c051c617e788afe50...4008201a747e4146f0dbf9ecff2d315ea2c856e5?src=pr)

Patch:
diff --git a/README.md b/README.md
index 6320755..661c24e 100644
--- a/README.md
+++ b/README.md
@@ -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',
diff --git a/src/web-auth/index.js b/src/web-auth/index.js
index 753ea03..924055f 100644
--- a/src/web-auth/index.js
+++ b/src/web-auth/index.js
@@ -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',
@@ -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']),
diff --git a/src/web-auth/popup.js b/src/web-auth/popup.js
index 6f29e83..e19151f 100644
--- a/src/web-auth/popup.js
+++ b/src/web-auth/popup.js
@@ -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' }, {
@@ -179,7 +179,7 @@ Popup.prototype.signupAndLogin = function (options, cb) {
         }
         return cb(err);
       }
-      _this.login(options, cb);
+      _this.loginWithCredentials(options, cb);
     });
 };
 
diff --git a/src/web-auth/redirect.js b/src/web-auth/redirect.js
index 376b4b3..a2a1208 100644
--- a/src/web-auth/redirect.js
+++ b/src/web-auth/redirect.js
@@ -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, [
@@ -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' }
@@ -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);
   });
 };
 


Test patch:
diff --git a/test/web-auth/popup.test.js b/test/web-auth/popup.test.js
index c2d70c4..70df4dd 100644
--- a/test/web-auth/popup.test.js
+++ b/test/web-auth/popup.test.js
@@ -146,7 +146,7 @@ describe('auth0.WebAuth.popup', function () {
         });
       });
 
-      this.auth0.popup.login({
+      this.auth0.popup.loginWithCredentials({
         connection: 'the_connection',
         nonce: '123',
         state: '456',
diff --git a/test/web-auth/redirect.test.js b/test/web-auth/redirect.test.js
index 084d4b2..99c819e 100644
--- a/test/web-auth/redirect.test.js
+++ b/test/web-auth/redirect.test.js
@@ -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',
@@ -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',
@@ -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');
     });
 
diff --git a/test/web-auth/web-auth.test.js b/test/web-auth/web-auth.test.js
index 004d317..451b4fe 100644
--- a/test/web-auth/web-auth.test.js
+++ b/test/web-auth/web-auth.test.js
@@ -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');
       });
@@ -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',
@@ -688,7 +688,7 @@ describe('auth0.WebAuth', function () {
         });
       });
 
-      this.auth0.signupAndLogin({
+      this.auth0.signupAndAuthorize({
         connection: 'the_connection',
         email: 'me@example.com',
         password: '123456',