Skip to content

Commit 54e8285

Browse files
committed
Merge remote-tracking branch 'upstream/master' into facebook_login
2 parents 6546610 + f82122f commit 54e8285

File tree

9 files changed

+35
-12
lines changed

9 files changed

+35
-12
lines changed

Auth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var getAuthForSessionToken = function(config, sessionToken) {
6464
var obj = results[0]['user'];
6565
delete obj.password;
6666
obj['className'] = '_User';
67+
obj['sessionToken'] = sessionToken;
6768
var userObject = Parse.Object.fromJSON(obj);
6869
cache.setUser(sessionToken, userObject);
6970
return new Auth(config, false, userObject);

ExportAdapter.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,21 @@ ExportAdapter.prototype.connect = function() {
3434
return this.connectionPromise;
3535
}
3636

37+
//http://regexr.com/3cn6m
38+
if (!this.mongoURI.match(/^mongodb:\/\/((.+):(.+)@)?([^:@]+):([^:]+)\/(.+?)$/gm)) {
39+
throw new Error("Invalid mongoURI: " + this.mongoURI)
40+
}
41+
var usernameStart = this.mongoURI.indexOf('://') + 3;
42+
var lastAtIndex = this.mongoURI.lastIndexOf('@');
43+
var encodedMongoURI = this.mongoURI;
44+
var split = null;
45+
if (lastAtIndex > 0) {
46+
split = this.mongoURI.slice(usernameStart, lastAtIndex).split(':');
47+
encodedMongoURI = this.mongoURI.slice(0, usernameStart) + encodeURIComponent(split[0]) + ':' + encodeURIComponent(split[1]) + this.mongoURI.slice(lastAtIndex);
48+
}
49+
3750
this.connectionPromise = Promise.resolve().then(() => {
38-
return MongoClient.connect(this.mongoURI);
51+
return MongoClient.connect(encodedMongoURI, {uri_decode_auth:true});
3952
}).then((db) => {
4053
this.db = db;
4154
});
@@ -232,7 +245,7 @@ ExportAdapter.prototype.handleRelationUpdates = function(className,
232245
}
233246

234247
if (op.__op == 'Batch') {
235-
for (x of op.ops) {
248+
for (var x of op.ops) {
236249
process(x, key);
237250
}
238251
}

RestQuery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ function includePath(config, auth, response, path) {
434434
function findPointers(object, path) {
435435
if (object instanceof Array) {
436436
var answer = [];
437-
for (x of object) {
437+
for (var x of object) {
438438
answer = answer.concat(findPointers(x, path));
439439
}
440440
return answer;

RestWrite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ RestWrite.prototype.handleFollowup = function() {
371371
};
372372
delete this.storage['clearSessions'];
373373
return this.config.database.destroy('_Session', sessionQuery)
374-
.then(this.handleFollowup);
374+
.then(this.handleFollowup.bind(this));
375375
}
376376
};
377377

functions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ var express = require('express'),
88
var router = new PromiseRouter();
99

1010
function handleCloudFunction(req) {
11-
// TODO: set user from req.auth
1211
if (Parse.Cloud.Functions[req.params.functionName]) {
1312
return new Promise(function (resolve, reject) {
1413
var response = createResponseObject(resolve, reject);
1514
var request = {
16-
params: req.body || {}
15+
params: req.body || {},
16+
user: req.auth && req.auth.user || {}
1717
};
1818
Parse.Cloud.Functions[req.params.functionName](request, response);
1919
});

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ addParseCloud();
2424
// and delete
2525
// "databaseURI": a uri like mongodb://localhost:27017/dbname to tell us
2626
// what database this Parse API connects to.
27-
// "cloud": relative location to cloud code to require
27+
// "cloud": relative location to cloud code to require, or a function
28+
// that is given an instance of Parse as a parameter. Use this instance of Parse
29+
// to register your cloud code hooks and functions.
2830
// "appId": the application id to host
2931
// "masterKey": the master key for requests to this app
3032
// "facebookAppIds": an array of valid Facebook Application IDs, required
@@ -52,7 +54,14 @@ function ParseServer(args) {
5254
}
5355
if (args.cloud) {
5456
addParseCloud();
55-
require(args.cloud);
57+
if (typeof args.cloud === 'function') {
58+
args.cloud(Parse)
59+
} else if (typeof args.cloud === 'string') {
60+
require(args.cloud);
61+
} else {
62+
throw "argument 'cloud' must either be a string or a function";
63+
}
64+
5665
}
5766

5867
cache.apps[args.appId] = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"jasmine": "^2.3.2"
2626
},
2727
"scripts": {
28-
"test": "TESTING=1 jasmine"
28+
"test": "TESTING=1 ./node_modules/.bin/jasmine"
2929
},
3030
"engines": {
3131
"node": ">=4.1"

spec/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function normalize(obj) {
153153
return '[' + obj.map(normalize).join(', ') + ']';
154154
}
155155
var answer = '{';
156-
for (key of Object.keys(obj).sort()) {
156+
for (var key of Object.keys(obj).sort()) {
157157
answer += key + ': ';
158158
answer += normalize(obj[key]);
159159
answer += ', ';
@@ -192,7 +192,7 @@ function mockFacebook() {
192192

193193
function clearData() {
194194
var promises = [];
195-
for (conn in DatabaseAdapter.dbConnections) {
195+
for (var conn in DatabaseAdapter.dbConnections) {
196196
promises.push(DatabaseAdapter.dbConnections[conn].deleteEverything());
197197
}
198198
return Promise.all(promises);

users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function handleLogIn(req) {
7373
'authProvider': 'password'
7474
},
7575
restricted: false,
76-
expiresAt: Parse._encode(expiresAt).iso
76+
expiresAt: Parse._encode(expiresAt)
7777
};
7878

7979
if (req.info.installationId) {

0 commit comments

Comments
 (0)