Skip to content

Conversation

@gormus
Copy link

@gormus gormus commented Jun 27, 2015

I haven't seen a way to get authenticated user's data. Returning user's uid as status' value, would be much helpful, I think.

// Define auth object, set crossDomain if is necessary
var Auth = new Backbone.Drupal.Auth({crossDomain: true , drupal8: false });

// Request executed in sync mode
var drupal_user_id = Auth.login('admin', 'password');

if(drupal_user_id) {
  console.log('Auth Works');

  var User = new Backbone.Drupal.Models.User({uid: drupal_user_id});
  User.fetch({
    success: function (user) {
      // User attributes.
      console.log('User', user.attributes);
    }
  });

}
else {
  console.log('Auth Error');
}

I haven't seen a way to get authenticated user's data. Returning user's uid as status' value, would be much helpful, I think.

// Define auth object, set crossDomain if is necessary
var Auth = new Backbone.Drupal.Auth({crossDomain: true , drupal8: false });

// Request executed in sync mode
var drupal_user_id = Auth.login('admin', 'password');

if(drupal_user_id) {
  console.log('Auth Works');

  var User = new Backbone.Drupal.Models.User({uid: drupal_user_id});
  User.fetch({
    success: function (user) {
      // User attributes.
      console.log('User', user.attributes);
    }
  });

}
else {
  console.log('Auth Error');
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should not have been changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant