Resetea contraseña solo con credenciales inválidas, errores solucionados

This commit is contained in:
Juan Ferrer Toribio 2017-10-06 12:36:46 +02:00
parent 7c7763eb0a
commit 1c6ca3ef62
1 changed files with 29 additions and 12 deletions

View File

@ -29,6 +29,8 @@ var Locale ={
"Error al actualizar" "Error al actualizar"
,"Microsoft Access 2003 is not installed": ,"Microsoft Access 2003 is not installed":
"Microsoft Access 2003 no está instalado en el sistema" "Microsoft Access 2003 no está instalado en el sistema"
,"MDB file not found":
"No se encontro el fichero MDB"
} }
}; };
@ -219,10 +221,12 @@ var App =
login: function () login: function ()
{ {
var clearPassword;
try {
var user = this.$('user').value; var user = this.$('user').value;
var password = this.$('password').value; var password = this.$('password').value;
try {
if (!user || user === '') if (!user || user === '')
throw new Error (_('Enter a user name')); throw new Error (_('Enter a user name'));
if (!password || password === '') if (!password || password === '')
@ -250,6 +254,7 @@ var App =
switch (dbError.NativeError) switch (dbError.NativeError)
{ {
case 1045: // Access denied case 1045: // Access denied
clearPassword = true;
errorMsg = _('Bad login'); errorMsg = _('Bad login');
break; break;
case 2003: // Can't connect case 2003: // Can't connect
@ -308,10 +313,7 @@ var App =
} }
catch (e) catch (e)
{ {
this.regWrite (Conf.dsPath, 'PWD', '', 'REG_SZ'); this._catchError (e, clearPassword);
this._disableUi (false);
this.resetForm ();
this.showMessage (e.message);
} }
}, },
@ -346,18 +348,33 @@ var App =
alert (_('Error while updating') +': '+ e.message); alert (_('Error while updating') +': '+ e.message);
} }
this._disableUi (false);
try { try {
if (this.fso.fileExists (this.mdbFile)) if (!this.fso.fileExists (this.mdbFile))
throw new Error (_('MDB file not found'));
this.openMdb (); this.openMdb ();
} }
catch (e) 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 () openMdb: function ()
{ {
var remember = this.$('remember').checked ? 1 : 0; var remember = this.$('remember').checked ? 1 : 0;