From 1c6ca3ef62e309e765b1939294c4fe7a6caedde8 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 6 Oct 2017 12:36:46 +0200 Subject: [PATCH] =?UTF-8?q?Resetea=20contrase=C3=B1a=20solo=20con=20creden?= =?UTF-8?q?ciales=20inv=C3=A1lidas,=20errores=20solucionados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main.js b/src/main.js index cd25077..17db8d9 100755 --- a/src/main.js +++ b/src/main.js @@ -29,6 +29,8 @@ var Locale ={ "Error al actualizar" ,"Microsoft Access 2003 is not installed": "Microsoft Access 2003 no está instalado en el sistema" + ,"MDB file not found": + "No se encontro el fichero MDB" } }; @@ -214,15 +216,17 @@ var App = _onEnterClick: function () { this._disableUi (true, _('Loading')); - setTimeout (function () {App.login();}, 0); + setTimeout (function () {App.login ();}, 0); }, login: function () { - var user = this.$('user').value; - var password = this.$('password').value; + var clearPassword; try { + var user = this.$('user').value; + var password = this.$('password').value; + if (!user || user === '') throw new Error (_('Enter a user name')); if (!password || password === '') @@ -250,6 +254,7 @@ var App = switch (dbError.NativeError) { case 1045: // Access denied + clearPassword = true; errorMsg = _('Bad login'); break; case 2003: // Can't connect @@ -308,10 +313,7 @@ var App = } catch (e) { - this.regWrite (Conf.dsPath, 'PWD', '', 'REG_SZ'); - this._disableUi (false); - this.resetForm (); - this.showMessage (e.message); + this._catchError (e, clearPassword); } }, @@ -346,18 +348,33 @@ var App = alert (_('Error while updating') +': '+ e.message); } - this._disableUi (false); - try { - if (this.fso.fileExists (this.mdbFile)) - this.openMdb (); + if (!this.fso.fileExists (this.mdbFile)) + throw new Error (_('MDB file not found')); + + this.openMdb (); } catch (e) { - this.showMessage (e.message); + this._catchError (e); } }, + _catchError: function (error, clearPassword) + { + if (error) + { + if (!this.$('remember').checked || clearPassword) + this.regWrite (Conf.dsPath, 'PWD', '', 'REG_SZ'); + + this.showMessage (error.message); + } + + this._disableUi (false); + this.$('user').focus (); + this.$('user').select (); + }, + openMdb: function () { var remember = this.$('remember').checked ? 1 : 0;