Skip to content

Login issue with different token and sessid #37

@Saneesh

Description

@Saneesh

Hello,
I'm trying to build a mobile app using angular-drupal. After configure everything, when I call the user_login() in my controller, it shows 'NOT A VALID USER!' message.

myApp.controller("TestController", ['$scope', '$http', 'shared', 'drupal', function ($scope, $http, shared, drupal) {
  var qsStoreId = 1;

  drupal.user_login('Admin', 'Admin@123').then(function(data) {
    console.log(data);
    if (data.user.uid) {
      console.log('User exists!');
    }
    else {
      console.log('NOT A VALID USER!');
    }
  });
}]);

In Firefox console, I can see three calls as follows (user/login.json, session/token and connect.json )

Call : POST http://mysite/?q=drupalgap/user/login.json
Response:
{
  "sessid": "SZHvoUQY76BR0EphigNuROAhlSosveXyOW17bsUD2VE",
  "session_name": "SESS31bd58610f7362c1ad5ccecaf06b294e",
  "token": "7Wwtz-akDJoF-4bNBbW_4w1z1EljPVRYsyXw4dh0JAE",
  "user": {
    "uid": "1",
    "name": "Admin",
    ...
  }
}

When it gets the token it returns a new token.

http://mysite/?q=services/session/token
Response:
lxmxpeboGGyH3hc88zZ2uj4RNKRHbqhY_hMa8yfGxIw

When it calls 'connect', session_name is same but the sessid is different.

http://mysite/?q=drupalgap/system/connect.json
Response:
{
  "sessid": "ei4lHs9z8_W5i4XypOgjPJLwph8Bx_Brvh8Odk_aUaA",
  "session_name": "SESS31bd58610f7362c1ad5ccecaf06b294e",
  "user": {
    "uid": 0,
    "hostname": "127.0.0.1",
    "roles": { "1": "anonymous user" },
    "cache": 0,
    "timestamp": 1476790053
  },
  "remote_addr": "127.0.0.1",
  ...
}

Might be because of this reason, I'm not getting user login success message.

I'm using Drupal 7 as backend. Instead of 'drupalgap' service endpoint I tried with a service called 'api' as mentioned in the tutorial(https://www.npmjs.com/package/angular-drupal) but still shows 'NOT A VALID USER!' message.

How can I fix this issue?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions