1 (edited by teixeira.diogo.2002 2021-07-20 22:14:09)

Topic: Block access

Hello guys, I need help.
I want to make a mini login system in which if the students.access record is in YES mode, it gives access to the form's content.
If bootlean is in NO mode, then a message appears saying "No rights" and does not give access.
could you do what I said?

My English is not very good, I'm sorry
Compliments
Diogo Teixeira

P.S- Attached is an image of the database I created and i have the database connect to MYSQL

Post's attachments

Attachment icon Captura de ecrã 2021-07-20 225215.jpg 86.66 kb, 14 downloads since 2021-07-20 

Re: Block access

Olá Diogo,
It can be done but is there a reason why you don't want to use the login and authorisation facilities that MVD already has?
You could then just use something like the 'admin' flag to either allow or deny access.
Alternatively, you could set up 2 'roles' - 'Access' and 'NoAccess' and allow or deny access that way (this is perhaps more robust because you could use extra 'roles' to grant different levels of access.
Have a look at the attached to see if it's of any use;  the passwords are the same as the userids ('admin' and 'diogo' have full access, 'derek' has no access).  These settings can be changed via the menu (Options / Users).
Derek.

Post's attachments

Attachment icon access.zip 341 kb, 58 downloads since 2021-07-21 

3 (edited by teixeira.diogo.2002 2021-07-21 08:28:22)

Re: Block access

Hello derek

Thanks for the support
Is it possible to show the login data in a form?
Like for example:
If not activated, the error message appears.
If you have activated it, the name "Welcome antónio" appears on the form.
Also all changes are made for that user only.
I don't know if you can do it in MVD.

I sent the tables from my database as an attachment

Compliments
Diogo Teixeira

Post's attachments

Attachment icon Pictures.rar 39.69 kb, 46 downloads since 2021-07-21 

4 (edited by derek 2021-07-21 21:57:09)

Re: Block access

Hi Diogo,
Yes, it's possible.  You can either show the login data in a pop-up message or you can display it on any form by using a label. 
Using a label is perhaps more helpful because it is always visible.
In my previous example, a user role was used to either allow or prohibit access to the application but perhaps it is too limited? 
So in this new example and to give you more of an idea how user roles can be applied, users Admin and Diogo have access (full access) but user Derek now has 'read only' access.
For 'read only' access,
1.  the data can still be viewed but buttons to add or delete data are hidden on Form1,
2.  the  button to save data on Form2 is hidden
3.  the button to save data on Form3 is hidden
4.  the date column in Form2.tablegrid1 is hidden (for whatever reason!).
5.  the edit fields on Form2 are read only
6.  the edit fields on Form3 are read only
All of the above is just configuration and doesn't require a script - have a look at screenshot1 in the attachment to see how to configure it (any object can be configured like this, not just a button or an edit field).
So by using 'user roles' in combination with different 'role' settings for various objects, you can do quite a lot very easily.
As before, the passwords are the same as the Userids.
Derek.

Post's attachments

Attachment icon access2.zip 493.73 kb, 71 downloads since 2021-07-21 

Re: Block access

Hello Derek

Thanks for the help smile

Compliments
Diogo Teixeira

Re: Block access

Hello Derek
I try your code but doesen´t work, because I have the database connect to a MYSQL Server
How i can make that work?

Compliments
Diogo Teixeira

7 (edited by ehwagner 2021-07-22 19:43:48)

Re: Block access

It works the same. What version of MVD are you using? You need to be on version 6 for standard access control. Also, make sure the tables "_Role" and "_User" are defined in your MySql database.

Re: Block access

Hello ehwagner, thanks for the advice

I am working in another computer with MVD 6.5 and It´s working.

Thanks

Complements
Diogo Teixeira