X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Pman.Login.js;h=234b9c099d3eef4ef42aea03dc812eec73172906;hp=c9f00e5d90cd0abeab680b802131113463a1a86c;hb=c1af5e6bb6064e88469651271f4d9aaff34d69c0;hpb=5b06378b7a64a662c690eb9436525a58c73d0d27 diff --git a/Pman.Login.js b/Pman.Login.js index c9f00e5d..234b9c09 100644 --- a/Pman.Login.js +++ b/Pman.Login.js @@ -36,6 +36,8 @@ Pman.Login = new Roo.util.Observable({ versionWarn: false, sending : false, + checkConnection : false, // the Roo.data.Connection for checking if still authenticated. + onLoad : function() // called on page load... { // load @@ -105,8 +107,10 @@ Pman.Login = new Roo.util.Observable({ return; } this.sending = true; - - Roo.Ajax.request({ + if (!this.checkConnection) { + this.checkConnection = new Roo.data.Connection(); + } + this.checkConnection.request({ url: baseURL + '/Login.js', params: { getAuthUser: true @@ -153,7 +157,16 @@ Pman.Login = new Roo.util.Observable({ this.fillAuth(res.data); this.checkFails =0; - Pman.onload(); + + + if (Pman.onload) { + Pman.onload(); + } + if (Pman.Login.callback) { + Pman.Login.callback(); + + } + return false; }, fillAuth: function(au) { @@ -161,7 +174,8 @@ Pman.Login = new Roo.util.Observable({ this.authUserId = au.id; this.authUser = au; this.lastChecked = new Date(); - Pman.fireEvent('authrefreshed', au); + // if login is used on other applicaitons.. + if (Pman.fireEvent) { Pman.fireEvent('authrefreshed', au); } //Pman.Tab.FaxQueue.newMaxId(au.faxMax); @@ -197,7 +211,7 @@ Pman.Login = new Roo.util.Observable({ Pman.Login.intervalID = window.setInterval(function() { Pman.Login.check(false); }, 120000); // every 120 secs = 2mins.. - + return true; }, @@ -245,15 +259,15 @@ Pman.Login = new Roo.util.Observable({ Roo.MessageBox.alert("Error", "Fill in your email address"); return; } - Roo.Ajax.request({ - url: baseURL + '/Login.js', + new Pman.Request({ + url: baseURL + '/Login.js', + mask : "Sending Password Reset email", params: { passwordRequest: n }, method: 'POST', - success: function(response, opts) { // check successfull... + success: function(res) { // check successfull... - var res = Pman.processResponse(response); if (!res.success) { // error! Roo.MessageBox.alert("Error" , res.errorMsg ? res.errorMsg : "Problem Requesting Password Reset"); return; @@ -291,8 +305,9 @@ Pman.Login = new Roo.util.Observable({ //act.result.errorMsg// invalid form element list... Pman.Login.dialog.el.unmask(); - Roo.MessageBox.alert("Error", act.result.errorMsg ? act.result.errorMsg : - "Login failed - communication error - try again."); + var msg = act.result.errorMsg || act.result.message; + msg = msg || "Login failed - communication error - try again."; + Roo.MessageBox.alert("Error", msg); }, actioncomplete: function(re, act) { @@ -306,10 +321,13 @@ Pman.Login = new Roo.util.Observable({ //Roo.get('loading').show(); Roo.get('loading-mask').show(); } - - Pman.onload(); - + if (Pman.onload) { + Pman.onload(); + } + if (Pman.Login.callback) { + Pman.Login.callback(); + } } } @@ -341,7 +359,7 @@ Pman.Login = new Roo.util.Observable({ if (ev.keyCode == 13) { Pman.Login.dialog.el.mask("Logging in"); Pman.Login.form.doAction('submit', { - url: baseURL + '/Login.json', + url: baseURL + '/Login', method: 'POST' }); } @@ -389,14 +407,22 @@ Pman.Login = new Roo.util.Observable({ ef.dom.style.margin = 10; this.form.render(ef.dom); - // logoprefix comes from base config. - Pman.Login.form.el.createChild({ + // logoprefix comes from base config - normally the owner company logo... + // ??? + + var img = typeof(appLogo) != 'undefined' && appLogo.length ? appLogo : + rootURL + '/Pman/'+appNameShort + '/templates/images/logo.gif' ; + + Pman.Login.form.el.createChild({ tag: 'img', - src: rootURL + '/Pman/'+appNameShort + '/templates/images/logo.gif', + src: img, style: 'margin-bottom: 10px;' }, Pman.Login.form.el.dom.firstChild - ); + ).on('error', function() { + this.dom.style.visibility = 'hidden'; + this.dom.style.height = '10px'; + }); var vp = this.dialog.getLayout().add('center', new Roo.ContentPanel(ef, { autoCreate : true, @@ -423,19 +449,23 @@ Pman.Login = new Roo.util.Observable({ this.resizeToLogo.defer(1000,this); return; } - var w = Ext.lib.Dom.getViewWidth() - 100; - var h = Ext.lib.Dom.getViewHeight() - 100; + var w = Roo.lib.Dom.getViewWidth() - 100; + var h = Roo.lib.Dom.getViewHeight() - 100; Pman.Login.dialog.resizeTo(Math.max(350, Math.min(sz.width + 30, w)),Math.min(sz.height+200, h)); Pman.Login.dialog.center(); }, - show: function (modal) + show: function (modal, cb) { if (this.disabled) { return; } + + + + this.callback = cb; // used for non-pman usage.. modal = modal || false; if (Pman.Login.authUserId < 0) { // logout!? return; @@ -459,12 +489,18 @@ Pman.Login = new Roo.util.Observable({ } //incomming._node = tnode; + // why we want this non-modal???? this.form.reset(); this.dialog.modal = !modal; this.dialog.show(); this.dialog.el.unmask(); this.resizeToLogo.defer(1000,this); + // if we have not created a provider.. do it now... + if (!Roo.state.Manager.getProvider().expires) { + Roo.state.Manager.setProvider(new Roo.state.CookieProvider()); + } + this.form.setValues({ 'username' : Roo.state.Manager.get('Pman.Login.username.'+appNameShort, ''),