Created
September 30, 2015 20:48
-
-
Save RubyRonin/6d8a35e7abfe8b70b1c3 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
.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