1 dump('entering auth/session.js\n');
3 if (typeof auth == 'undefined') auth = {};
4 auth.session = function (controller) {
6 JSAN.use('util.error'); this.error = new util.error();
7 JSAN.use('main.network'); this.network = new main.network();
8 this.controller = controller;
13 auth.session.prototype = {
15 'init' : function () {
18 var init = this.network.request(
20 'open-ils.auth.authenticate.init',
21 [ this.controller.view.name_prompt.value ]
26 this.key = this.network.request(
28 'open-ils.auth.authenticate.complete',
30 this.controller.view.name_prompt.value,
34 this.controller.view.password_prompt.value
40 this.error.sdump('D_AUTH','auth.session.key = ' + this.key + '\n');
42 if (Number(this.key) == 0) {
43 throw('Invalid name/password combination.');
44 } else if (instanceOf(this.key,ex)) {
45 throw(this.key.err_msg());
48 if (typeof this.on_init == 'function') {
49 this.error.sdump('D_AUTH','auth.session.on_init()\n');
55 var error = 'open-ils.auth.authenticate.init returned false\n';
56 this.error.sdump('D_ERROR',error);
57 this.controller.logoff();
62 var error = 'Error on auth.session.init(): ' + E + '\n';
63 this.error.sdump('D_ERROR',error);
65 if (typeof this.on_init_error == 'function') {
66 this.error.sdump('D_AUTH','auth.session.on_init_error()\n');
67 this.on_init_error(E);
71 if (typeof this.on_init == 'function') {
72 this.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
79 'close' : function () {
80 this.error.sdump('D_AUTH','auth.session.close()\n');
82 if (typeof this.G.on_close == 'function') {
83 this.error.sdump('D_AUTH','auth.session.on_close()\n');
90 dump('exiting auth/session.js\n');