Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update backbone.drupal.js #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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');
}
@@ -104,9 +104,10 @@ Backbone.Drupal.Auth = (function(Backbone, $, _){
}

// Define specific parametres to be used in all future request.
$.ajaxSetup(settings);
jQuery.ajaxSetup(settings);
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