简体   繁体   中英

Issue with parse.com user signup not working

Using parse.com and javaScript SDK 1.6.7.

The below code is used to register new users on my site, it works.

What is really strange is, if I register a user, they are logged in and forwarded to the expected page. If I then log them out and straight away register another user, they are created in the back end but are not logged in and therefore the forwarder does't work.

Has anyone else experienced this issue with parse.com??? I dont see anything wrong with my code that would create this issue?

I've tested in Chrome and Safari and the issue happens in both, it follows the same pattern overtime - as in first user works, second user doesn't and so on.

I've tried clearing cache etc which hasn't helped either. Wonder if its an issue with parse? anyone else experienced this or know how to resolve?

$('#SignUp').click(function(e) {

    UserSignUp();
});



function UserSignUp() {

   var user = new Parse.User();


   userFirstname = $('#firstnamesu').val();
   userLastname = $('#lastnamesu').val();
   userUsername = $('#usernamesu').val();
   userGender = $('#gendersu').val();
   Email = $('#emailsu').val();
   PWP = $('#passwordsu').val();
   console.log("2");


   user.set("FirstName", userFirstname);
   user.set("LastName", userLastname);
   user.set("username", userUsername);
   user.set("gender", userGender);
   user.set("email", Email);
   user.set("password", PWP);

   console.log("3");

var uri = encodeURI('http://domain_home.html');
  user.signUp(null, {

    success: function(user) {
         if (!user.existed()) {
                window.location.href = uri;
            } 

    },
    error: function(user, error) {
      // Show the error message somewhere and let the user try again.

    }
  });

};

Logout code //////////////Allows the user to logout from the site///////////////////////////////////

$(document).ready(function() {
    $('.logout').click(function(e) {
        Parse.User.logOut();
        window.location.href = "index.html";
    });
});

After hours of testing this and basically recreating the page from scratch I identified the issue. It was completely unrelated to the js code, on my html page the sign up fields were held within a form, by removing the form element the problem is resolved.

I'm not suggesting this is an issue with parse, but anytime I try and put the fields into a <form> the issue presents itself.

I'm using a bootstrap html template so something could be complicating it further from that angle also.

I guess if anyone has an issue like this, try removing the form element.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM