From 531495d51726fc87367c0ad046498bc8ceb0c081 Mon Sep 17 00:00:00 2001 From: Osman Gormus Date: Fri, 26 Jun 2015 18:23:12 -0700 Subject: [PATCH] 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'); } --- backbone.drupal.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backbone.drupal.js b/backbone.drupal.js index 7ab09bb..83ecc8c 100644 --- a/backbone.drupal.js +++ b/backbone.drupal.js @@ -104,9 +104,10 @@ Backbone.Drupal.Auth = (function(Backbone, $, _){ } // Define specific parametres to be used in all future request. - $.ajaxSetup(settings); + jQuery.ajaxSetup(settings); - status=true; + // Change 'status' value to authenticated user's {user.uid}. + status=data.user.uid; } }); }