Created
November 27, 2017 15:57
-
-
Save addisonElliott/9baafffe970270a3fdea0acc620f6d49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("../util/errorCodes.js"); | |
Parse.Cloud.define("login", function(request, response) | |
{ | |
if (request.user == null) | |
{ | |
response.error(Parse.Error.OPERATION_FORBIDDEN, "You must be logged on to call this function."); | |
return; | |
} | |
var lastLogin = new Date(); | |
// Update last login field in user to be current date/time | |
request.user.set("lastLogin", lastLogin); | |
request.user.save(null, { | |
useMasterKey: true | |
}).then(function(user) { | |
response.success({"lastLogin": lastLogin}); | |
}, function(error) { | |
response.error("Unable to perform action in login function: " + error.message); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment