backbone.drupal
backbone.drupal copied to clipboard
Update backbone.drupal.js
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');
}