Skip to content

Instantly share code, notes, and snippets.

@RubyRonin
Created September 30, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RubyRonin/6d8a35e7abfe8b70b1c3 to your computer and use it in GitHub Desktop.
Save RubyRonin/6d8a35e7abfe8b70b1c3 to your computer and use it in GitHub Desktop.
?
.controller('LoginCtrl', function($scope, $state) {
$scope.data = {};
$scope.signupEmail = function(){
//Create a new user on Pasre
var user = new Parse.User();
user.set("username", $scope.data.username);
user.set("password", $scope.data.password);
user.set("email", $scope.data.email);
user.signUp(null, {
success: function(user) {
alert("sucess!");
$state.go('dashboard'); //causes app to change "state" or "view" upon success, required the injection of $state
},
error: function(user, error) {
alert("Error: " + error.code + " " +error.message);
}
});
};
$scope.loginEmail = function(){
Parse.User.logIn($scope.data.username, $scope.data.password, {
success: function(user) {
// Do stuff after successful login.
console.log(user);
alert("success!");
$state.go('app.dashboard');
},
error: function(user, error) {
// The login failed. Check error to see why.
alert("error!");
}
});
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment