I did a sample to login and signup to parse.com and i was working , then i retry to login and signup the error is:
Failed to load resource: the server responded with a status of 400 (Bad Request) signin.html:56 login error:invalid session token
My Signin Code:
Parse.initialize("I removed the keys here");
var item = Parse.Object.extend("User");
$("#signin-submit").click(function(event){
event.preventDefault();
var username = $("#signin-username").val();
var password = $("#signin-password").val();
Parse.User.logIn(username,password, {error: function(user,error){
console.log("login error:"+error.message);
}
});
});
$("#fb").click(function(event){
Parse.User.logOut();
});
</script>
<script type="text/javascript">
var myApp = angular.module('signinPage',[]);
myApp.controller('mainController', ['$scope', function($scope) {
}])
;
My signup Code:
Parse.initialize("I removed the keys");
var item = Parse.Object.extend("User");
$("#signup-submit").click(function(event){
event.preventDefault();
var first = $("#signup-name").val();
var last = $("#signup-family").val();
var username = $("#signup-username").val();
var email = $("#signup-email").val();
var password = $("#signup-password").val();
var country = $("#signup-country").val();
var newUser = new item();
newUser.set("first",first);
newUser.set("last",last);
newUser.set("username",username);
newUser.set("email",email);
newUser.set("password",password);
newUser.set("country",country);
newUser.save(null,{success:function(){
console.log('youre signed up');
}, error: function(user , error){
console.log("signup eroor:"+error.message);
}});
});
Why are using save method to register a user instead of signUp method ?? From Parse documentation:
Note that we used the signUp method, not the save method. New Parse.Users should always be created using the signUp method. Subsequent updates to a user can be done by calling save.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.