Impedita la creazione di utenti e password che contengano spazi

git-svn-id: svn://10.65.10.50/trunk@1338 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1995-05-10 08:58:39 +00:00
parent 0bc5884a64
commit a578bce098

View File

@ -21,6 +21,7 @@ class TSet_users : public TRelation_application
virtual int write(const TMask& m);
virtual int rewrite(const TMask& m);
void enable_aut(TMask& m);
static bool user_handler(TMask_field& f, KEY key);
static bool password_handler(TMask_field& f, KEY key);
virtual void init_query_mode(TMask& m) { enable_aut(m);}
virtual void init_insert_mode(TMask& m) { enable_aut(m);}
@ -31,12 +32,24 @@ public:
TSet_users() : _msk(NULL), _rel(NULL) {}
};
bool TSet_users::user_handler(TMask_field& f, KEY key)
{
if (!f.mask().query_mode() || !f.to_check(key)) return TRUE;
const bool ok = f.get().find(' ') < 0;
if (!ok) return f.error_box("Il nome dell'utente non deve contenere spazi");
return ok;
}
bool TSet_users::password_handler(TMask_field& f, KEY key)
{
if (f.mask().mode() == MODE_QUERY || key != K_ENTER) return TRUE;
const bool ok = f.get().len() > 3 ;
if (!ok) f.error_box("La password deve essere lunga almeno 4 caratteri");
if (f.mask().query_mode() || key != K_ENTER) return TRUE;
const bool ok = f.get().len() > 3 && f.get().find(' ') < 0;
if (!ok) return f.error_box("La password deve essere lunga almeno 4 caratteri e non contenere spazi");
return ok;
}
@ -67,6 +80,7 @@ bool TSet_users::user_create()
_msk = new TMask("ba1400a") ;
_rel = new TRelation(LF_USER);
_msk->field(F_MU).disable();
_msk->set_handler(F_USER, user_handler);
_msk->set_handler(F_PASSWORD, password_handler);
return TRUE;
}