Merge remote-tracking branch 'upstream/master' into facebook_login

This commit is contained in:
Taylor Stine
2016-02-02 17:57:17 -05:00
9 changed files with 35 additions and 12 deletions

View File

@@ -64,6 +64,7 @@ var getAuthForSessionToken = function(config, sessionToken) {
var obj = results[0]['user'];
delete obj.password;
obj['className'] = '_User';
obj['sessionToken'] = sessionToken;
var userObject = Parse.Object.fromJSON(obj);
cache.setUser(sessionToken, userObject);
return new Auth(config, false, userObject);

View File

@@ -34,8 +34,21 @@ ExportAdapter.prototype.connect = function() {
return this.connectionPromise;
}
//http://regexr.com/3cn6m
if (!this.mongoURI.match(/^mongodb:\/\/((.+):(.+)@)?([^:@]+):([^:]+)\/(.+?)$/gm)) {
throw new Error("Invalid mongoURI: " + this.mongoURI)
}
var usernameStart = this.mongoURI.indexOf('://') + 3;
var lastAtIndex = this.mongoURI.lastIndexOf('@');
var encodedMongoURI = this.mongoURI;
var split = null;
if (lastAtIndex > 0) {
split = this.mongoURI.slice(usernameStart, lastAtIndex).split(':');
encodedMongoURI = this.mongoURI.slice(0, usernameStart) + encodeURIComponent(split[0]) + ':' + encodeURIComponent(split[1]) + this.mongoURI.slice(lastAtIndex);
}
this.connectionPromise = Promise.resolve().then(() => {
return MongoClient.connect(this.mongoURI);
return MongoClient.connect(encodedMongoURI, {uri_decode_auth:true});
}).then((db) => {
this.db = db;
});
@@ -232,7 +245,7 @@ ExportAdapter.prototype.handleRelationUpdates = function(className,
}
if (op.__op == 'Batch') {
for (x of op.ops) {
for (var x of op.ops) {
process(x, key);
}
}

View File

@@ -434,7 +434,7 @@ function includePath(config, auth, response, path) {
function findPointers(object, path) {
if (object instanceof Array) {
var answer = [];
for (x of object) {
for (var x of object) {
answer = answer.concat(findPointers(x, path));
}
return answer;

View File

@@ -371,7 +371,7 @@ RestWrite.prototype.handleFollowup = function() {
};
delete this.storage['clearSessions'];
return this.config.database.destroy('_Session', sessionQuery)
.then(this.handleFollowup);
.then(this.handleFollowup.bind(this));
}
};

View File

@@ -8,12 +8,12 @@ var express = require('express'),
var router = new PromiseRouter();
function handleCloudFunction(req) {
// TODO: set user from req.auth
if (Parse.Cloud.Functions[req.params.functionName]) {
return new Promise(function (resolve, reject) {
var response = createResponseObject(resolve, reject);
var request = {
params: req.body || {}
params: req.body || {},
user: req.auth && req.auth.user || {}
};
Parse.Cloud.Functions[req.params.functionName](request, response);
});

View File

@@ -24,7 +24,9 @@ addParseCloud();
// and delete
// "databaseURI": a uri like mongodb://localhost:27017/dbname to tell us
// what database this Parse API connects to.
// "cloud": relative location to cloud code to require
// "cloud": relative location to cloud code to require, or a function
// that is given an instance of Parse as a parameter. Use this instance of Parse
// to register your cloud code hooks and functions.
// "appId": the application id to host
// "masterKey": the master key for requests to this app
// "facebookAppIds": an array of valid Facebook Application IDs, required
@@ -52,7 +54,14 @@ function ParseServer(args) {
}
if (args.cloud) {
addParseCloud();
require(args.cloud);
if (typeof args.cloud === 'function') {
args.cloud(Parse)
} else if (typeof args.cloud === 'string') {
require(args.cloud);
} else {
throw "argument 'cloud' must either be a string or a function";
}
}
cache.apps[args.appId] = {

View File

@@ -25,7 +25,7 @@
"jasmine": "^2.3.2"
},
"scripts": {
"test": "TESTING=1 jasmine"
"test": "TESTING=1 ./node_modules/.bin/jasmine"
},
"engines": {
"node": ">=4.1"

View File

@@ -153,7 +153,7 @@ function normalize(obj) {
return '[' + obj.map(normalize).join(', ') + ']';
}
var answer = '{';
for (key of Object.keys(obj).sort()) {
for (var key of Object.keys(obj).sort()) {
answer += key + ': ';
answer += normalize(obj[key]);
answer += ', ';
@@ -192,7 +192,7 @@ function mockFacebook() {
function clearData() {
var promises = [];
for (conn in DatabaseAdapter.dbConnections) {
for (var conn in DatabaseAdapter.dbConnections) {
promises.push(DatabaseAdapter.dbConnections[conn].deleteEverything());
}
return Promise.all(promises);

View File

@@ -73,7 +73,7 @@ function handleLogIn(req) {
'authProvider': 'password'
},
restricted: false,
expiresAt: Parse._encode(expiresAt).iso
expiresAt: Parse._encode(expiresAt)
};
if (req.info.installationId) {