Skip to content

Commit 7f8e1cd

Browse files
committed
remove deprecated methods. all tests passing.
1 parent 2a10b9c commit 7f8e1cd

File tree

16 files changed

+144
-124
lines changed

16 files changed

+144
-124
lines changed

dist/amd/dl.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://github.com/doubleleft/dl-api-javascript
44
*
55
* @copyright 2014 Doubleleft
6-
* @build 6/26/2014
6+
* @build 7/1/2014
77
*/
88
(function(define) { 'use strict';
99
define(function (require) {
@@ -583,15 +583,6 @@ DL.Auth.prototype.register = function(provider, data) {
583583
return promise;
584584
};
585585

586-
/**
587-
* @method authenticate
588-
* @see register
589-
*/
590-
DL.Auth.prototype.authenticate = function() {
591-
console.log("auth.authenticate method is deprecated. Please use auth.register.");
592-
return this.register.apply(this, arguments);
593-
};
594-
595586
/**
596587
* Verify if user is already registered, and log-in if succeed.
597588
* @method login
@@ -612,22 +603,13 @@ DL.Auth.prototype.authenticate = function() {
612603
DL.Auth.prototype.login = function(provider, data) {
613604
var promise, that = this;
614605
if (typeof(data)==="undefined") { data = {}; }
615-
promise = this.client.post('auth/' + provider + '/verify', data);
606+
promise = this.client.post('auth/' + provider + '/login', data);
616607
promise.then(function(data) {
617608
that._registerToken(data);
618609
});
619610
return promise;
620611
};
621612

622-
/**
623-
* @method verify
624-
* @see login
625-
*/
626-
DL.Auth.prototype.verify = function() {
627-
console.log("auth.verify method is deprecated. Please use auth.login.");
628-
return this.login.apply(this, arguments);
629-
};
630-
631613
/**
632614
* Send a 'forgot password' confirmation email to target user email address.
633615
* @method forgotPassword
@@ -1683,6 +1665,7 @@ DL.Channel.SSE.prototype.subscribe = function(event, callback) {
16831665
/**
16841666
*/
16851667
DL.Channel.SSE.prototype._trigger = function(event, data) {
1668+
console.log("Trigger: ", event, data);
16861669
// always try to dispatch default message handler
16871670
if (event.indexOf('state:')===-1 && this.callbacks._default) {
16881671
this.callbacks._default.apply(this, [event, data]);

dist/dl.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://github.com/doubleleft/dl-api-javascript
44
*
55
* @copyright 2014 Doubleleft
6-
* @build 6/26/2014
6+
* @build 7/1/2014
77
*/
88
(function(window) {
99
//
@@ -10128,15 +10128,6 @@ DL.Auth.prototype.register = function(provider, data) {
1012810128
return promise;
1012910129
};
1013010130

10131-
/**
10132-
* @method authenticate
10133-
* @see register
10134-
*/
10135-
DL.Auth.prototype.authenticate = function() {
10136-
console.log("auth.authenticate method is deprecated. Please use auth.register.");
10137-
return this.register.apply(this, arguments);
10138-
};
10139-
1014010131
/**
1014110132
* Verify if user is already registered, and log-in if succeed.
1014210133
* @method login
@@ -10157,22 +10148,13 @@ DL.Auth.prototype.authenticate = function() {
1015710148
DL.Auth.prototype.login = function(provider, data) {
1015810149
var promise, that = this;
1015910150
if (typeof(data)==="undefined") { data = {}; }
10160-
promise = this.client.post('auth/' + provider + '/verify', data);
10151+
promise = this.client.post('auth/' + provider + '/login', data);
1016110152
promise.then(function(data) {
1016210153
that._registerToken(data);
1016310154
});
1016410155
return promise;
1016510156
};
1016610157

10167-
/**
10168-
* @method verify
10169-
* @see login
10170-
*/
10171-
DL.Auth.prototype.verify = function() {
10172-
console.log("auth.verify method is deprecated. Please use auth.login.");
10173-
return this.login.apply(this, arguments);
10174-
};
10175-
1017610158
/**
1017710159
* Send a 'forgot password' confirmation email to target user email address.
1017810160
* @method forgotPassword
@@ -11228,6 +11210,7 @@ DL.Channel.SSE.prototype.subscribe = function(event, callback) {
1122811210
/**
1122911211
*/
1123011212
DL.Channel.SSE.prototype._trigger = function(event, data) {
11213+
console.log("Trigger: ", event, data);
1123111214
// always try to dispatch default message handler
1123211215
if (event.indexOf('state:')===-1 && this.callbacks._default) {
1123311216
this.callbacks._default.apply(this, [event, data]);

dist/dl.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/auth.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,6 @@ DL.Auth.prototype.register = function(provider, data) {
9393
return promise;
9494
};
9595

96-
/**
97-
* @method authenticate
98-
* @see register
99-
*/
100-
DL.Auth.prototype.authenticate = function() {
101-
console.log("auth.authenticate method is deprecated. Please use auth.register.");
102-
return this.register.apply(this, arguments);
103-
};
104-
10596
/**
10697
* Verify if user is already registered, and log-in if succeed.
10798
* @method login
@@ -122,22 +113,13 @@ DL.Auth.prototype.authenticate = function() {
122113
DL.Auth.prototype.login = function(provider, data) {
123114
var promise, that = this;
124115
if (typeof(data)==="undefined") { data = {}; }
125-
promise = this.client.post('auth/' + provider + '/verify', data);
116+
promise = this.client.post('auth/' + provider + '/login', data);
126117
promise.then(function(data) {
127118
that._registerToken(data);
128119
});
129120
return promise;
130121
};
131122

132-
/**
133-
* @method verify
134-
* @see login
135-
*/
136-
DL.Auth.prototype.verify = function() {
137-
console.log("auth.verify method is deprecated. Please use auth.login.");
138-
return this.login.apply(this, arguments);
139-
};
140-
141123
/**
142124
* Send a 'forgot password' confirmation email to target user email address.
143125
* @method forgotPassword

src/channel/sse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ DL.Channel.SSE.prototype.subscribe = function(event, callback) {
9191
/**
9292
*/
9393
DL.Channel.SSE.prototype._trigger = function(event, data) {
94+
console.log("Trigger: ", event, data);
9495
// always try to dispatch default message handler
9596
if (event.indexOf('state:')===-1 && this.callbacks._default) {
9697
this.callbacks._default.apply(this, [event, data]);

tests/api.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
window.client = new DL.Client({
2-
url: "http://dl-api.ddll.co/",
2+
url: "http://dl-api.dev/index.php/",
33
appId: '1',
4-
key: "q1uU7tFtXnLad6FIGGn2cB+gxcx64/uPoDhqe2Zn5AE="
4+
key: "4c5f2f5ed5cebe26955829ab948128fc"
55
});
66

7+
window.ascii_rand = function(length) {
8+
var str = "";
9+
for (var i=0; i < length; i++) {
10+
var charCode = 97 + Math.floor((Math.random() * 25));
11+
str += String.fromCharCode(charCode);
12+
}
13+
return str; // + ((new Date()).getTime().toString().substr(8))
14+
}
15+
716
test("API", function() {
8-
ok( client.url == "http://dl-api.ddll.co/", "url OK");
17+
ok( client.url == "http://dl-api.dev/index.php/", "url OK");
918
ok( client.appId == "1", "'appId' OK");
10-
ok( client.key == "test", "'secret' OK");
19+
ok( client.key == "4c5f2f5ed5cebe26955829ab948128fc", "'secret' OK");
1120
});

tests/auth/email.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
asyncTest("Authentication: Email", function() {
1+
asyncTest("Auth: register by email", function() {
22
expect(3);
33

4-
client.auth.authenticate('email', {
5-
4+
var email = ascii_rand(8) + "@" + ascii_rand(5) + ".com";
5+
6+
client.auth.register('email', {
7+
email: email,
68
name: "Endel Dreyer",
79
password: "teste"
10+
811
}).then(function(response) {
9-
ok(client.auth.currentUser.email == "[email protected]", "currentUser.email");
12+
ok(client.auth.currentUser.email == email, "currentUser.email");
1013
ok(client.auth.currentUser.name == "Endel Dreyer", "currentUser.name");
14+
// ok(client.auth.currentUser.password == "teste", "currentUser.password");
1115

1216
client.auth.logout();
1317
ok(client.auth.currentUser == null, "logout");
18+
19+
}).done(function() {
1420
start();
21+
1522
});
1623

1724
});

tests/auth/email_login.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
asyncTest("Authentication: Email login (success)", function() {
2+
expect(4);
3+
4+
// register dummy user first
5+
var email = ascii_rand(8) + "@" + ascii_rand(5) + ".com";
6+
client.auth.register('email', {
7+
email: email,
8+
name: "Endel Dreyer",
9+
password: "teste"
10+
}).done(function() {
11+
12+
client.auth.logout();
13+
ok(client.auth.currentUser == null, "should have clean session before login");
14+
15+
// test for successful login
16+
client.auth.login('email', {
17+
email: email,
18+
name: "Endel Dreyer",
19+
password: "teste"
20+
}).then(function(response) {
21+
ok(client.auth.currentUser.email == email, "currentUser.email");
22+
ok(client.auth.currentUser.name == "Endel Dreyer", "currentUser.name");
23+
24+
client.auth.logout();
25+
ok(client.auth.currentUser == null, "logout");
26+
27+
}).done(function() {
28+
start();
29+
});
30+
31+
});
32+
});
33+
34+
asyncTest("Authentication: Email login (error)", function() {
35+
expect(1);
36+
37+
// register dummy user first
38+
var email = ascii_rand(8) + "@" + ascii_rand(5) + ".com";
39+
client.auth.register('email', {
40+
email: email,
41+
name: "Endel Dreyer",
42+
password: "teste"
43+
}).done(function() {
44+
45+
var promise = client.auth.login('email', {
46+
47+
name: "Endel Dreyer",
48+
password: "i'm using the wrong password here"
49+
}).then(function(response) {
50+
ok(false, "shouldn't login with invalid password");
51+
start();
52+
53+
}, function(response) {
54+
ok(typeof(response.error)=="string", "Password invalid");
55+
56+
}).done(function() {
57+
start();
58+
});
59+
60+
61+
});
62+
63+
});

tests/auth/email_verify.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/auth/facebook.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
asyncTest("Authentication: Facebook", function() {
2-
expect(3);
2+
expect(4);
33

44
FB.login(function(response) {
5-
client.auth.authenticate('facebook', response.authResponse).then(function(userdata) {
5+
data = response.authResponse;
6+
data.additional_field = "It's possible to add new fields when registering with facebook.";
7+
client.auth.register('facebook', data).then(function(userdata) {
68
FB.api('/me', function(me) { // match registered data with actual user info
79
ok(client.auth.currentUser.email == me.email, "currentUser.email");
810
ok(client.auth.currentUser.name == me.name, "currentUser.name");
11+
ok(client.auth.currentUser.additional_field == data.additional_field, "additional_field should be saved");
912
client.auth.logout();
1013
ok(client.auth.currentUser == null, "logout");
1114
start();
1215
});
1316
});
1417
}, {scope: 'email'});
1518
});
16-

0 commit comments

Comments
 (0)