var user = new Parse.User()
user.set("username", "my name");
user.set("password", "my pass");
user.set("email", "email@example.com"); // optional
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.
}
});
Parse.User.logIn("myname", "mypass").then(
function(user) {
// Do stuff after successful login.
},
function(error) {
// The login failed. Check error to see why.
}
);
Parse.User.logOut().then(function() {
// Do stuff
})
Parse.User.current()
// Initialize app
Parse.initialize('app-id', 'js-key')
// Function called once SDK is loaded
window.fbAsyncInit = function() {
// Initialize Facebook utilities
Parse.FacebookUtils.init({ // this line replaces FB.init({
appId : 'your-app-id', // Facebook App ID
status : true, // check Facebook Login status
cookie : true, // enable cookies to allow Parse to access the session
xfbml : true, // initialize Facebook social plugins on the page
version : 'v2.3' // point to the latest Facebook Graph API version
});
}
// Activate SDK
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Parse.FacebookUtils.logIn(null, {
success: function(user) {
if (!user.existed()) {
alert("User signed up and logged in through Facebook!");
} else {
alert("User logged in through Facebook!");
}
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});