1 dump('entering auth/session.js\n');
3 if (typeof auth == 'undefined') auth = {};
4 auth.session = function (view) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('util.network'); this.network = new util.network();
13 auth.session.prototype = {
15 'init' : function () {
18 var init = this.network.request(
21 [ this.view.name_prompt.value ]
26 var robj = this.network.request(
27 api.auth_complete.app,
28 api.auth_complete.method,
30 this.view.name_prompt.value,
34 this.view.password_prompt.value
40 if (robj.ilsevent == 0) {
41 this.key = robj.payload.authtoken;
42 this.authtime = robj.payload.authtime;
44 var error = robj.ilsevent + ' : ' + this.error.get_ilsevent( robj.ilsevent );
45 this.error.sdump('D_AUTH','auth.session.init: ' + error + '\n');
50 this.error.sdump('D_AUTH','auth.session.key = ' + this.key + '\n');
52 if (typeof this.on_init == 'function') {
53 this.error.sdump('D_AUTH','auth.session.on_init()\n');
59 var error = 'open-ils.auth.authenticate.init returned false\n';
60 this.error.sdump('D_ERROR',error);
65 var error = 'Error on auth.session.init(): ' + js2JSON(E) + '\n';
66 this.error.sdump('D_ERROR',error);
68 if (typeof this.on_init_error == 'function') {
69 this.error.sdump('D_AUTH','auth.session.on_init_error()\n');
70 this.on_init_error(E);
72 if (typeof this.on_error == 'function') {
73 this.error.sdump('D_AUTH','auth.session.on_error()\n');
78 /* This was for testing
79 if (typeof this.on_init == 'function') {
80 this.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
87 'close' : function () {
88 this.error.sdump('D_AUTH','auth.session.close()\n');
90 if (typeof this.on_close == 'function') {
91 this.error.sdump('D_AUTH','auth.session.on_close()\n');
98 dump('exiting auth/session.js\n');