From ffa7d1b1f1b3e1495df8210c82e1e3e6d28ab7a9 Mon Sep 17 00:00:00 2001 From: Taylor Stine Date: Tue, 2 Feb 2016 08:13:13 -0500 Subject: [PATCH 1/2] Added req.auth.user to parse cloud functions --- Auth.js | 1 + functions.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Auth.js b/Auth.js index faa1ffd641..ad9056549a 100644 --- a/Auth.js +++ b/Auth.js @@ -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); diff --git a/functions.js b/functions.js index cf4aeb28bf..74d481b08e 100644 --- a/functions.js +++ b/functions.js @@ -13,7 +13,8 @@ function handleCloudFunction(req) { 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); }); From 35b6b16918d51302ab74d5c1da79d092cf94f516 Mon Sep 17 00:00:00 2001 From: Taylor Stine Date: Tue, 2 Feb 2016 16:14:42 -0500 Subject: [PATCH 2/2] Removed user todo from cloud function --- functions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/functions.js b/functions.js index 74d481b08e..ee2ac54125 100644 --- a/functions.js +++ b/functions.js @@ -8,7 +8,6 @@ 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);