PDA

View Full Version : Change Button Password from Another Button on Another Form


ABC123

Rudy16
04-11-2008, 11:01 AM
Hi everyone,

First let me state that I'm new to Alpha 5 and could not find the following in Alpha's Help System. I set up passwords on certain buttons such as launching an Administrative Menu. I've set the password via the Properities of that button.

Is ther a way I can set up another button on a password/change form so a user in a run-time environment can change these various passwords in other buttons whenever he deems it necessary?

Hope this is clear to all.

Tom Cone Jr
04-25-2008, 08:19 AM
Hello, Rudy.

No, the password you embed in the properties of the button object can't be changed by the runtime user or administrator. The runtime engine will not permit design changes to the form. The button lives in the form, so it can't be changed.

There are a number of ways people solve this design issue. Since you mention needing to be able to change numbers of passwords on numbers of buttons, perhaps its time to get acquainted with the built in security system. There you define users and groups. YOu put users in groups. The security system requires the user to log in when they open the database. This means the user_name can be retrieved by any script you write. The user_name can be used to determine what groups a user belongs to, by any script you write. Your button script could check to see if the current user belongs to a group that's authorized to use the button. The Runtime Administrator can change passwords and reassign folks to different groups. If you want to see how this might work build a simple database, enter a few dummy records, define your security settings for a couple of imaginary users, build a form that has a button on it and then zip the entire database and post it here. Tell us the Admninstrator password, the name of the form you've built, and which group you want to be able to run the button script. We can then download your sample, modify your button script and you'll have a working example that can be used with other buttons in your app.

-- tom

uploads are handled by clicking the "Go Advanced" button from your message editors screen, and then choosing "Manage Attachments"

Rudy16
04-25-2008, 08:45 AM
Hey Tom,

Just set up 3 groups. One Group is BrowseOnly, one is Administrators and the last is AllowReports.

I will try and figure out the script behind the button to check if the user logged in is a member of the Administrators and if so, open the admin form.

Rudy

Tom Cone Jr
04-25-2008, 09:04 AM
tip:

User_groups() will return a list of groups the current user belongs to.

is_one_of() can be used to determine if a particular group is in the list

Rudy16
04-25-2008, 09:42 AM
It's me again,
I created a db with a main menu and client form.
There are 2 users set up.
1) Tim pw is yes member of administrators Group
2) Rudy pw is no member of Browse Only Group

When the Administrator Menu button is pressed I want to check if the user logged in is a member of the administrators group and if so open the client form.

I used a backup database command but how can I get it to you so you can set up the button script?

Tom Cone Jr
04-25-2008, 09:45 AM
Rudy, slow down, you're movin' too fast.

Check post#2 in this thread. Read the PS. Zip your database and attach it to a reply here

Rudy16
04-25-2008, 10:28 AM
Here it is Tom.

There are 2 users set up.
1) Tim pw is yes member of administrators Group
2) Rudy pw is no member of Browse Only Group

When the Administrator Menu button is pressed I want to check if the user logged in is a member of the administrators group and if so open the client form.

crimmelcp
04-25-2008, 10:41 AM
Rudy
Here is an Example
see attached zip file

Unzip
it will create a folder called login

Charlie Crimmel

crimmelcp
04-25-2008, 11:59 AM
added the scriptds to make the sample calendar work

Charlie crimmel

Tom Cone Jr
04-25-2008, 12:24 PM
Rudy, I've modified your button's onPush event script. It contains two actions:

a) a message box is displayed if the user doesn't belong to Administrators group
b) the second form is opened if the user does belong to Administrators group

Both are accomplished by making the actions conditional.

Let me know if you have questions.

Suggest you unzip this to an empty folder on your machine.

MoGrace
04-25-2008, 01:09 PM
Rudy
Here is an Example
see attached zip file

Unzip
it will create a folder called login

Charlie Crimmel
And the password is....?

Nevermind I found it - use the lastname. Ctrl-Shift on load will take you to the controlpanel.


There are 2 users set up.
1) Tim pw is yes member of administrators Group
2) Rudy pw is no member of Browse Only Group

Well that didn't work for Tom's example! What is the password for that "yes" or "no"? Oops Tim or Rudy is the password. You guys are making this hard for me!

MoGrace
04-25-2008, 01:30 PM
Ok Tom I have a question: How did you do that? There are only 2 tables and no records and no scripts - where did the login come from?

I opened the database in ver 7, apparently there is something there I cannot see.

MikeC
04-25-2008, 01:41 PM
Robin,
Go the the top menu bar, choose tools, choose Security, then choose Define Users and Groups

MoGrace
04-25-2008, 01:47 PM
Robin,
Go the the top menu bar, choose tools, choose Security, then choose Define Users and GroupsHAH! the one place I hadn't looked of course! I had seen it before but when I don't know how to do something I tend to forget about it. Now that I have a couple of good examples, perhaps I can use this feature.

christobal
04-25-2008, 02:41 PM
Have used ui_getPassword() (http://support.alphasoftware.com/alphafivehelpv9/Functions/UI_GET_PASSWORD().htm) on button or hotspot onPush events with great success. The variable "password" is set through an apps settings table value which is populated by the autoexec script.

christobal
04-25-2008, 03:00 PM
Have just whipped up an example of this functions use

Rudy16
04-25-2008, 05:18 PM
Tom,
I received your data base and I'm confiused. So what's now.
I thought you aere going to show me the syntax on how to code the "is_one_of() and "User_Groups() which would be placed on the Main Menu Button called "Administrative Menu" so when the user pushed it, the security test would occur.

I set up the users and groups and database login password which worked fine however after I selected my user name and password, instead of opening the Main Menu, it opened the control panel. When I selected the Main Menu form and pressed the Administration Menu Button, I received an "empty expression" error message.

Rudy16
04-25-2008, 06:21 PM
Very nice Charlie.

Once a user logs in with his name and password and procedes to the Main Menu and presses the "Maintain Users" button
- if the person logged in does not have adinistrative rights per security table,
- want to display a message "No Administrative Rights - see Administrator " and
exit the script and remain in the Main Menu so he can either Exit the application
or proceed to another Menu via another Button.
- if the person logged in "does" have administrative rights,
- want to Open the Administrative Form.

I changed my entry to a level 2 and still was able to proceed to "Maintain Users" on a Push. Is this an easy fix or am I way off base on this?

Thanks in advance for your patience with me.

Rudy

Tom Cone Jr
04-25-2008, 07:09 PM
Rudy, oops. I uploaded your old zip, instead of the modified one. Will fix and upload with a new filename. Standby.

Later...
Ok, here you go. Unzip this to an empty folder. Do not unzip it to your existing database folder. Open the database with vers 9. Log in as Rudy or Tim. Push the button on the Main Menu. Rudy cannot get to the second form, Tim, can. The work is done in the onPush event script for the Administrator Form button. Notice the conditional expressions attached to the two Actions.

This can be improved further, but I'd need the Administrator's password for the database, which you have not yet supplied.

-- tom

Rudy16
04-25-2008, 10:25 PM
This is nice! I'm really excited. The administrators password is dobie.

When the user is a member of the user_group, it opens the form. When the user is not, it drops into the Control Panel. It would be nice if a message box appeared that stated "Not Authorized" and allowed the user to stay on the Main Menu and go somewhere else where he/she is allowed.

Can you modify the Conditionsl statement with an if, else, then statement?

I also created a security Menu using the A5_Security_Option's and it's great. This way the clubhouse president who is the administrator can add or delete users and change passwords.

Thanks again,
Rudy

Tom Cone Jr
04-26-2008, 06:51 AM
When the user is not, it drops into the Control Panel.

That will only happen if you close the Main Menu form. In my example this never happens because I removed the close form ACTION from your previous script. Are you seeing this in my example? If so tell me the exact sequence of steps that drops Rudy down to the control panel after he logs in.

In my example the Main Menu form is opening immediately after log in. I made it the startup form for the database. My "Administrator Form" button does NOT close the form. The second form is opened on top of it.

--tom

ps dobie is NOT the administrator password for the database you posted here. I still can't log in as Administrator

Rudy16
04-26-2008, 07:33 AM
I see it. Your help is so much appreciated. I've spent hours researching the How To's in Alpha's Help System (there is sooo much to learn). I found that some of the examples leave of lot to be desired (Syntax not clearly defined), however, I have to say that Alpha5 blows away the competition.

I'm working on an application for our Clubhouse. I live in a Senior Citizen community. They currently have an Access system that is "sooo bad". What I have now blows away their application and I'm just starting out. I can't wait to become proficient in Alpha like all of you. I too will help newbie's like you and others on this board once I master Alpha.

The clubhouse does not have a network server setup. I beleive that the computers are attached via cable? I have to check their configuration one day.

Again, my thanks to all that spent their valuable time to provide me with some code examples. Once this is cleaned up, I would share it with anyone that was interested.

crimmelcp
04-26-2008, 09:20 AM
Rudy
I changed the code on the maintain users button
to give message

"User has No Administrative Rights"

see attached zip

Rudy16
04-26-2008, 11:03 AM
I unzipped ot to the same directory however when I ran the app, enyered my name and password, a windows popped up stating tha "It could not load the specified form "Main Menu", using a Default form" appeared and when I clicked OK, it took me to the Maintain Users Form??

Tom Cone Jr
04-26-2008, 11:27 AM
I can't help you without a current copy of your database. Your posts will be easier to understand if you don't use the word "it". That's a word that means something to you, but could mean a variety of things to your readers. All I can tell is that you unzipped something to some directory and have a problem. Not much for me to go on, is there?

The error message suggest the database you were opening does not contain a form named "Main Menu". I have no clue why that should be unless you've renamed or deleted the form I used in my example.