-1

I want use Back4App with angularjs application, for simple user login.

Can I do this and how?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Jenia
  • 9
  • 1

1 Answers1

1

Yes this can be done and is done. Use the javascript doc on parse.com http://docs.parseplatform.org/js/guide/

Also there is a nodejs tool. https://www.npmjs.com/package/angular-parse Are you familiar with Angularjs?

Load angularjs and parse in HTML

In your controller, pass data from your sign in form:

$scope.submitFormReg = function(newUser){
    var user = new Parse.User();
    user.set("username", newUser.user);
    user.set("password", newUser.pass);
    user.set("email", newUser.email);

    user.signUp(null, {
      success: function(user) {
        // Hooray! Let them use the app now.
      },
      error: function(user, error) {
        // Show the error message somewhere and let the user try again.
        alert("Error: " + error.code + " " + error.message);

        Parse.User.logOut().then(() => {
        });
      }
    });
};

$scope.submitFormLogin = function(newUser){
    Parse.User.logIn(newUser.user, newUser.pass, {
      success: function(user) {
        // Do stuff after successful login.
    $location.path('/');

  },
  error: function(user, error) {
    // The login failed. Check error to see why.
    alert(newUser + " login failed: " + error);
  }
    });
};
Morgan Hayes
  • 321
  • 2
  • 25