Changeset 9535

Show
Ignore:
Timestamp:
05/08/08 13:12:40 (1 week ago)
Author:
erickson
Message:

created a fully synchronous version of the login method

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Open-ILS/web/js/dojo/openils/User.js

    r9437 r9535  
    8787         * Logs in, sets the authtoken/authtime vars, and fetches the logged in user 
    8888         */ 
    89         login : function(args, onComplete) { 
     89        login_async : function(args, onComplete) { 
    9090            var _u = this; 
    9191 
     
    102102                alert(seed); 
    103103                var loginInfo = { 
     104                    username : args.username, 
    104105                    password : hex_md5(seed + hex_md5(args.passwd)),  
    105106                    type : args.type, 
     
    121122            initReq.send(); 
    122123        }, 
     124 
     125        login : function(args) { 
     126            var _u = this; 
     127            if (!args) args = {}; 
     128            if (!args.username) args.username = _u.username; 
     129            if (!args.passwd) args.passwd = _u.passwd; 
     130            if (!args.type) args.type = _u.login_type; 
     131            if (!args.location) args.location = _u.location; 
     132 
     133            var seed = fieldmapper.standardRequest( 
     134                ['open-ils.auth', 'open-ils.auth.authenticate.init'], 
     135                [args.username] 
     136            ); 
     137 
     138            var loginInfo = { 
     139                username : args.username, 
     140                password : hex_md5(seed + hex_md5(args.passwd)),  
     141                type : args.type, 
     142                org : args.location, 
     143            }; 
     144 
     145            var data = fieldmapper.standardRequest( 
     146                ['open-ils.auth', 'open-ils.auth.authenticate.complete'], 
     147                [loginInfo] 
     148            ); 
     149 
     150            _u.authtoken = data.payload.authtoken; 
     151            if (!openils.User.authtoken) openils.User.authtoken = _u.authtoken; 
     152            _u.authtime = data.payload.authtime; 
     153            if (!openils.User.authtime) openils.User.authtime = _u.authtime; 
     154        }, 
     155 
    123156     
    124157        /**