signalpoint / jDrupal

A JavaScript Library and API for Drupal Applications
http://jdrupal.tylerfrankenstein.com/
GNU General Public License v2.0
76 stars 38 forks source link

After logging in, Access denied for user anonymous #74

Open BarryAbrams opened 7 years ago

BarryAbrams commented 7 years ago

I'm having some trouble staying logged in with jDrupal 7. I'm using phonegap.

I can perform a successful system_connect, and user_login, but I'm getting "Access denied for user anonymous" when I try a node_save afterwards. If I run an Console.log(Drupal) I can see that user.uid is set to 0, before or after user_login.

I'm not sure what I'm doing wrong. Here's a simplified version of my code:

system_connect({
  success: function(result) {
    console.log("connected to drupal");
      user_login("admin", "password", {
        success:function(result){
            console.log("logged in");
            var node = {
              title: "Hello World",
              type: "article"
            };
            node_save(node, {
              success: function(result) {
                alert("Saved node #" + result.nid);
              }
            });
        },
        error:function(xhr, status, message){
          alert(message);
        }
    });
  }
});
liquidcms commented 5 years ago

Yes, years later.. but hoping jDrupal is still an active project (but sadly i think it isn't).

I have the same issue. When i do a user_login() the result is the logged in user object; but this isn't being set to Drupal.user and my guess is this has something to do with not getting new CSRF token. I am not seeing any console.log errors though except for CORB warnings which i assume are not too big a deal as the user object for the logged in user is returned successfully.

liquidcms commented 5 years ago

i think this issue is with system_connect. It returns a sessid, session_name; but data.user is for anon user.

perhaps a bit of a rabbit hole here as this is pretty old now and likely no longer supported.

signalpoint commented 3 years ago

@BarryAbrams @liquidcms Add a couple more years... and I am experiencing this too w/ cordova + jdrupal 7 + ios.

I'll be investigating how to solve this issue, but wanted to let you know that I don't experience this when building a web application, and do not experience it with cordova + jdrupal 7 + android.