Merge remote-tracking branch 'upstream/master' into facebook_login
This commit is contained in:
1
Auth.js
1
Auth.js
@@ -64,6 +64,7 @@ var getAuthForSessionToken = function(config, sessionToken) {
|
|||||||
var obj = results[0]['user'];
|
var obj = results[0]['user'];
|
||||||
delete obj.password;
|
delete obj.password;
|
||||||
obj['className'] = '_User';
|
obj['className'] = '_User';
|
||||||
|
obj['sessionToken'] = sessionToken;
|
||||||
var userObject = Parse.Object.fromJSON(obj);
|
var userObject = Parse.Object.fromJSON(obj);
|
||||||
cache.setUser(sessionToken, userObject);
|
cache.setUser(sessionToken, userObject);
|
||||||
return new Auth(config, false, userObject);
|
return new Auth(config, false, userObject);
|
||||||
|
|||||||
@@ -34,8 +34,21 @@ ExportAdapter.prototype.connect = function() {
|
|||||||
return this.connectionPromise;
|
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(() => {
|
this.connectionPromise = Promise.resolve().then(() => {
|
||||||
return MongoClient.connect(this.mongoURI);
|
return MongoClient.connect(encodedMongoURI, {uri_decode_auth:true});
|
||||||
}).then((db) => {
|
}).then((db) => {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
});
|
});
|
||||||
@@ -232,7 +245,7 @@ ExportAdapter.prototype.handleRelationUpdates = function(className,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (op.__op == 'Batch') {
|
if (op.__op == 'Batch') {
|
||||||
for (x of op.ops) {
|
for (var x of op.ops) {
|
||||||
process(x, key);
|
process(x, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ function includePath(config, auth, response, path) {
|
|||||||
function findPointers(object, path) {
|
function findPointers(object, path) {
|
||||||
if (object instanceof Array) {
|
if (object instanceof Array) {
|
||||||
var answer = [];
|
var answer = [];
|
||||||
for (x of object) {
|
for (var x of object) {
|
||||||
answer = answer.concat(findPointers(x, path));
|
answer = answer.concat(findPointers(x, path));
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
|
|||||||
@@ -371,7 +371,7 @@ RestWrite.prototype.handleFollowup = function() {
|
|||||||
};
|
};
|
||||||
delete this.storage['clearSessions'];
|
delete this.storage['clearSessions'];
|
||||||
return this.config.database.destroy('_Session', sessionQuery)
|
return this.config.database.destroy('_Session', sessionQuery)
|
||||||
.then(this.handleFollowup);
|
.then(this.handleFollowup.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ var express = require('express'),
|
|||||||
var router = new PromiseRouter();
|
var router = new PromiseRouter();
|
||||||
|
|
||||||
function handleCloudFunction(req) {
|
function handleCloudFunction(req) {
|
||||||
// TODO: set user from req.auth
|
|
||||||
if (Parse.Cloud.Functions[req.params.functionName]) {
|
if (Parse.Cloud.Functions[req.params.functionName]) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
var response = createResponseObject(resolve, reject);
|
var response = createResponseObject(resolve, reject);
|
||||||
var request = {
|
var request = {
|
||||||
params: req.body || {}
|
params: req.body || {},
|
||||||
|
user: req.auth && req.auth.user || {}
|
||||||
};
|
};
|
||||||
Parse.Cloud.Functions[req.params.functionName](request, response);
|
Parse.Cloud.Functions[req.params.functionName](request, response);
|
||||||
});
|
});
|
||||||
|
|||||||
13
index.js
13
index.js
@@ -24,7 +24,9 @@ addParseCloud();
|
|||||||
// and delete
|
// and delete
|
||||||
// "databaseURI": a uri like mongodb://localhost:27017/dbname to tell us
|
// "databaseURI": a uri like mongodb://localhost:27017/dbname to tell us
|
||||||
// what database this Parse API connects to.
|
// 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
|
// "appId": the application id to host
|
||||||
// "masterKey": the master key for requests to this app
|
// "masterKey": the master key for requests to this app
|
||||||
// "facebookAppIds": an array of valid Facebook Application IDs, required
|
// "facebookAppIds": an array of valid Facebook Application IDs, required
|
||||||
@@ -52,7 +54,14 @@ function ParseServer(args) {
|
|||||||
}
|
}
|
||||||
if (args.cloud) {
|
if (args.cloud) {
|
||||||
addParseCloud();
|
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] = {
|
cache.apps[args.appId] = {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"jasmine": "^2.3.2"
|
"jasmine": "^2.3.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "TESTING=1 jasmine"
|
"test": "TESTING=1 ./node_modules/.bin/jasmine"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.1"
|
"node": ">=4.1"
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ function normalize(obj) {
|
|||||||
return '[' + obj.map(normalize).join(', ') + ']';
|
return '[' + obj.map(normalize).join(', ') + ']';
|
||||||
}
|
}
|
||||||
var answer = '{';
|
var answer = '{';
|
||||||
for (key of Object.keys(obj).sort()) {
|
for (var key of Object.keys(obj).sort()) {
|
||||||
answer += key + ': ';
|
answer += key + ': ';
|
||||||
answer += normalize(obj[key]);
|
answer += normalize(obj[key]);
|
||||||
answer += ', ';
|
answer += ', ';
|
||||||
@@ -192,7 +192,7 @@ function mockFacebook() {
|
|||||||
|
|
||||||
function clearData() {
|
function clearData() {
|
||||||
var promises = [];
|
var promises = [];
|
||||||
for (conn in DatabaseAdapter.dbConnections) {
|
for (var conn in DatabaseAdapter.dbConnections) {
|
||||||
promises.push(DatabaseAdapter.dbConnections[conn].deleteEverything());
|
promises.push(DatabaseAdapter.dbConnections[conn].deleteEverything());
|
||||||
}
|
}
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
|
|||||||
2
users.js
2
users.js
@@ -73,7 +73,7 @@ function handleLogIn(req) {
|
|||||||
'authProvider': 'password'
|
'authProvider': 'password'
|
||||||
},
|
},
|
||||||
restricted: false,
|
restricted: false,
|
||||||
expiresAt: Parse._encode(expiresAt).iso
|
expiresAt: Parse._encode(expiresAt)
|
||||||
};
|
};
|
||||||
|
|
||||||
if (req.info.installationId) {
|
if (req.info.installationId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user