Skip to content

Instantly share code, notes, and snippets.

@addisonElliott
Created November 27, 2017 15:57
Show Gist options
  • Save addisonElliott/9baafffe970270a3fdea0acc620f6d49 to your computer and use it in GitHub Desktop.
Save addisonElliott/9baafffe970270a3fdea0acc620f6d49 to your computer and use it in GitHub Desktop.
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