Hello All,

I am facing issue with Drupalgap, when i try to login with correct user name and password it reload page with all success API calls but user object still have uid 0. i have tried to debug the API calls manually and found that drupalgap/user/login.json is working fine and returning correct user object and just after that its calling drupalgap/system/connect.json that is returning token thats also successful but after that it will show uid 0 for user object. due to this reason system considering user as anonymous.

FYI: I am developing app from my localhost but the website is hosted on other server with sub-domain (Virtual Host) And I can successfully login and app works fine if i try using web-app from sub-domain.

Please help me to get rid of this.

Thanks

Comments

drupal786 created an issue. See original summary.

tyler.frankenstein’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

Most likely a CORS issue, I'd recommend reading up on CORS+Services|DrupalGap.

drupal786’s picture

I have setup cores and everything that is listed in troubleshooting section but still not working.

drupal786’s picture

I have also debugged and found that, at the time of login either by using Ripple or by PhoneGap Server IP its calling drupalgap/user/login.json and its returning correct data with actual uidm, but just after that drupalgap also call drupalgap/system/connect.json that is returning uid 0 always so due to this reason page reload and back to anonymous page or login page.

bduell’s picture

@drupal786 I'm having this same issue. Were you able to determine what it was?

Thanks!

bduell’s picture

@drupal786, along with CORS being setup on my Drupal server, I was able to get logins with cookies in the app on ios working by having the following environment:
cordova 9.0.0 (cordova-lib@9.0.1)
cordova-ios@5.1.1 (this doesn't work with cordova-ios@6+)

And along with my other phonegap plugins I needed these:

<plugin name="cordova-plugin-wkwebview-engine" spec="~1.2.2" />
<plugin name="cordova-plugin-wkwebviewxhrfix" spec="~0.1.0" />
<plugin name="cordova-plugin-wkwebview-inject-cookie" spec="~1.1.5" />
<plugin name="cordova-plugin-advanced-http" spec="~3.1.1" />

The key was this module that needs the following code at the bottom of your index.html file to work:

<!-- Cookie Support -->
<script type="text/javascript">
  document.addEventListener('deviceready', () => {
    let domain = (new URL(Drupal.settings.site_path));
    wkWebView.injectCookie(domain.hostname, '/');
  });
</script>

Hopefully this helps you - good luck!

gisle’s picture

Status: Postponed (maintainer needs more info) » Needs review

Looks like comments #6 provides enough information to resolve this, changing status.