Skip to content

Cloud Code check for "admin rights" #4007

Closed
@mginz83

Description

@mginz83
Parse.Cloud.define('adminLogin', function(request, response) {

	var username = request.params.username;
	var password = request.params.password;
	var emailPattern = request.params.emailPattern;
	var admin = false;
	
	Parse.User.logIn(username, password, {

		if (username.equals("EMAIL_ADDRESS_HERE")) {
			admin = true;
		}

  		success: function(user) {
    		// Do stuff after successful login.
  		},
  		error: function(user, error) {
    		// The login failed. Check error to see why.
  		}
	});

});

So, basically, what I want to happen is if a certain user tries to sign in, itll log in. For example, if I login with my email address and password, itll work.... however, if its anything OTHER than me, it fails....

I can easily do this inside of the application, but how is something like that done in cloud code?

I figure, if I put the code inside of success, then itll work regardless, and I dont want that. I want my cloudcode to determine if its me, if it is, were successful, if its not, we fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions