Topic: Password

Is there a sample project with password feature in here? I searched the forum but I couldn't find what I was looking for. There is a multi-user version but I like to have single user version using sqlite db.


On first run of the app no password asked. It's up to the user to set a password within app.
Once user sets up a password, on next run password asked. If wrong password entered then dialog message displayed such as wrong password etc.


here is a sample project for applying password feature:

Post's attachments

Attachment icon Password Test.zip 3.56 kb, 435 downloads since 2017-01-01 

Adam
God... please help me become the person my dog thinks I am.

2 (edited by derek 2017-01-01 19:05:08)

Re: Password

Hi Adam,
In the attachment, I've cut and pasted the code I usually use in my projects.
When the program is run for the very first time, there will obviously be no valid users so part of the script creates the first user automatically - the username in the attached example is 'adam' and the password is 'mvd' (but this initial setting can be changed in the script). 
Alternatively, you could leave that portion of the code out of the script entirely and just create your first user directly in the table using something like 'sqlitestudio'.
My example allows for more than one user to be created but works just the same with one user if that's what you want.  I wouldn't advise it as I think it will create problems if the only login details to your project get forgotten - but it's just my opinion.
Derek.

Post's attachments

Attachment icon adam password.zip 514.33 kb, 481 downloads since 2017-01-01 

Re: Password

Hi Derek,


Thanks a lot for the sample.....


I like having user names and passwords table and having ability to create more than 1 user to be created..


However, I need it to run without asking any username and password until user adds 1 or more within the application.

Adam
God... please help me become the person my dog thinks I am.

Re: Password

Please check it out

Post's attachments

Attachment icon Password Test_fixed.zip 5.49 kb, 454 downloads since 2017-01-02 

Dmitry.

Re: Password

Hi Dmitry,


Thanks a lot.................
Great stuff... Just as I wanted.


However, I realized that I missed one important area,
After setting up a password, user may decide not to use a password. Needs ability to delete set password.
I have added explaining notes on the form.


Please see the attached same sample project with notes

Post's attachments

Attachment icon Password Test 2.zip 6.38 kb, 409 downloads since 2017-01-02 

Adam
God... please help me become the person my dog thinks I am.

Re: Password

To delete password, just execute sql query to delete record with password.

SQLExecute('DELETE FROM password WHERE id=1');
Dmitry.

Re: Password

DriveSoft wrote:

To delete password, just execute sql query to delete record with password.

SQLExecute('DELETE FROM password WHERE id=1');

Thanks a lot Dmitry.......


I have associated the sql query to a button with warning message and it works fine - deletes the password.


After user adds and saves a password, on next visit to "frmAddEditPassw" I wanted "edExistingPassword" (Existing / Current Password) field to display saved password in alpha numeric characters. I tried the following but didn't work:

procedure frmAddEditPassw_edExistingPassword_OnChange (Sender: string);
begin
    frmAddEditPassw.edExistingPassword.Text := SQLExecute('SELECT password FROM password WHERE id = '+frmAddEditPassw.edExistingPassword.sqlValue);
end;

Delete button responds regardless there is a saved password or not atm. What I like to do but cannot is; if there is no value displayed in field "edExistingPassword" (Existing / Current Password) delete button becomes disabled or alternatively hidden. Please see the images below as a reference.


https://s24.postimg.org/ex0irh579/zzz_Test.png

Adam
God... please help me become the person my dog thinks I am.

Re: Password

Adam, I revised your last project to incorporate what I thought you wanted. But I see you entered another post which changed the design a little. See if you can use what I put together. If not, that's ok.

Post's attachments

Attachment icon Password Test 2 Revised.zip 584.85 kb, 403 downloads since 2017-01-03 

Re: Password

Hi EHW,


Thanks a lot for the revision...


Unless I'm missing something, there is no save button displayed on "frmAddEditPassw" so that I could test the revised version.
However, imho user friendly version would be as illustrated on the images above. It's almost done thanks to Dmitry...



Just needed showing password on  "edExistingPassword" (Existing / Current Password) field and enabling/disabling delete button according to value / no value on  "edExistingPassword"  field.


Here is updated version:

Post's attachments

Attachment icon Password Test 2 Updated.zip 6.95 kb, 407 downloads since 2017-01-03 

Adam
God... please help me become the person my dog thinks I am.

10 (edited by ehwagner 2017-01-03 16:50:33)

Re: Password

Adam, the SAVE button only shows after entering the second password when changing or removing the password. Keeping the two passwords empty will automatically remove the password. In my revision there is no need for the Delete button. Also. if you want to see the existing password, just remove the password character in the properties.

Re: Password

Ok Adam I revised your latest project to hide/unhide the delete button. See attached.

Post's attachments

Attachment icon Password Test 2 Updated (2).zip 583.68 kb, 443 downloads since 2017-01-03 

Re: Password

Hi EHW,


Thanks a lot...........................


Great stuff... Appreciated.

Adam
God... please help me become the person my dog thinks I am.

Re: Password

Hello Adam, EHW,
I was looking at your password issue again and trying to use standard MVD as much as possible.
So I've gone with using the usual tablegrid / edit forms for the users / passwords.  This allows you to have more than one user (which you said earlier was something you might want) and adding, changing and deleting needs no additional code.
And to reduce the script, I've used text hint functionality to reveal the passwords - just hover the mouse over the asterisks.
It's a different approach and might give you some ideas.
Derek.

Post's attachments

Attachment icon adam password with hints.zip 515.21 kb, 507 downloads since 2017-01-04 

Re: Password

Hi Derek,


Thanks a lot...................


That's a great stuff too... Now, we have two nice password options to use.
Once again thank you sooooooooo much guys............................................................

Adam
God... please help me become the person my dog thinks I am.