partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

Ext.data.Connection-sessionInjection.js (637B)


      1 /**
      2  * Enhancements for Ext.data.Connection:
      3  * 
      4  * Inject the session automatically on each request if a
      5  * session is available.
      6  */
      7 Ext.override(Ext.data.Connection, {
      8 	/**
      9 	 * Inject session header. I haven't found a better way to do
     10 	 * it :(
     11 	 */
     12 	setupHeaders: function (xhr, options, data, params) {
     13 		var session;
     14 		
     15 		if (!options.headers) {
     16 			options.headers = {};
     17 		}
     18 		
     19 		if (PartKeepr.getApplication() !== null) {
     20 			session = PartKeepr.getApplication().getSession();
     21 			if (session !== null) {
     22 				options.headers.session = session;
     23 			}
     24 		}
     25 		
     26 		var headers = this.callOverridden(arguments);
     27 		
     28 		return headers;
     29 	}
     30 
     31 });