pass the function result, not the function :) misc
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Sep 2005 15:55:41 +0000 (15:55 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 23 Sep 2005 15:55:41 +0000 (15:55 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1863 dcc99617-32d9-48b4-a31d-7c20da2025e4

Evergreen/staff_client/chrome/content/evergreen/auth/auth.js
Evergreen/staff_client/chrome/content/evergreen/util/file.js

index 6c4779e..3e92646 100644 (file)
@@ -384,7 +384,7 @@ function user_callback(request) {
                        enable_login_prompts(); return;
                }
        }
-       try { set_object_in_file('user_ou',user_ou); } catch(E) { handle_error(E); }
+       try { set_object_in_file('user_ou',user.home_ou()); } catch(E) { handle_error(E); }
        mw.G.user = user;
        mw.G.user_ou = user.home_ou();
        sdump('D_AUTH', "user: " + js2JSON(mw.G['user']) + '\n');
index 378f44d..c37a162 100644 (file)
@@ -7,10 +7,14 @@ var dirService = Components.classes["@mozilla.org/file/directory_service;1"].
 
 function set_object_in_file(file,obj) {
        try {
-               if (typeof(file)=='string') file = get_file( file );
-                var f = create_output_stream(file);
-                var obj_json = js2JSON( obj );
-                f.write( obj_json, obj_json.length ); f.close();
+               if (obj) {
+                       if (typeof(file)=='string') file = get_file( file );
+                       var f = create_output_stream(file);
+                       var obj_json = js2JSON( obj );
+                       f.write( obj_json, obj_json.length ); f.close();
+               } else {
+                       throw('Tried setting obj = ' + obj + '\n');
+               }
        } catch(E) {
                sdump('D_FILE', 'set_object_in_file: ' + js2JSON(E) + '\n');
                throw(E);
@@ -22,7 +26,8 @@ function get_object_in_file(file) {
                if (typeof(file)=='string') file = get_file( file );
                if (file.exists()) {
                        var f = create_input_stream(file);
-                       var obj = JSON2js( f.read(-1) );
+                       var data = f.read(-1);
+                       var obj = JSON2js( data );
                        f.close();
                        return obj;
                } else {