Jump to content

Login system Ask


Papang

Recommended Posts

Hi lavas,

I was creating a user login system using usernameand password, but there something less with the functions. Here belowdescription of the system.

  1. User should using an admin account (username:admin/password:123456)to login at the first time.
  2. When the user was login and stand as adminposition, user panel will appear and display 3 buttons which add, delete and view.
  3. When addbutton selected, add user panel will appear and display 2 empty string controlswhich username and password. To add other user, he/she just insertusername/password that they want, press add user button, those data will automaticallyinserted into the table and user admin will back to user panel.
  4. When deletebutton selected, delete user panel will appear and display 2 empty stringcontrols which username and password. To delete other user, he/she just insertusername/password that they want, press delete user button, those data will automaticallydeleted from the table and user admin will back to user panel. But IF username/password is not relevantwith table’s data, message box will appear (telling that username/passwordinserted are not available) and the string control will be empty.
  5. When viewbutton selected, user list panel will appear and show user table where usernameand password are stored. This table is readable-only. Press done and user adminwill back to user panel.
  6. When it done with editing user account, theuser admin can log out and try to login with other user account. The usernameand password inserted for authentication will be match with the data inside theuser table. Message box will be appearing to notify user IF username andpassword are wrong.
  7. Username/password cannot be empty. IF username/passwordis empty and login button pressed, message box will appear (telling that pleaseinsert your username or password).

Hopeanyone may solve this. sad.gif

Thank you.

Link to comment

Hello Papang,

First, thanks for uploading your code. That helps understand what you want to do.

I've reviewed it and it is hard to follow when you have many structures within structures. Try to avoid putting multiple event structures in the same loop: you might have deadlocks that are hard to debug. Also, the use of local variables to keep information between loops

Instead of modifying your code, I thought I'd prepare a Login Demo project for you to look at. It's based on a queued state machine, for which you can find examples in LabVIEW's help or templates. I've put many comments in the code for helping you expand on this example. I hope you find that this demo is useful to decompose all your use cases and create a login VI with the desired functions. Try modifying this base code to achieve the list of specifications you have. If you still have questions, come back... ;-)

Login demo.zip (LV 2009)

  • Like 1
Link to comment

Thank You François Normandin,

It was really help me, but I'm still do not know how to create this:

  • When addbutton selected, add user panel will appear and display 2 empty string controlswhich username and password. To add other user, he/she just insertusername/password that they want, press add user button, those data will automaticallyinserted into the table and user admin will back to user panel.
  • When deletebutton selected, delete user panel will appear and display 2 empty stringcontrols which username and password. To delete other user, he/she just insertusername/password that they want, press delete user button, those data will automaticallydeleted from the table and user admin will back to user panel. ButIF username/password is not relevantwith table’s data, message box will appear (telling that username/passwordinserted are not available) and the string control will be empty.

Can you assist me?

Hello Papang,

First, thanks for uploading your code. That helps understand what you want to do.

I've reviewed it and it is hard to follow when you have many structures within structures. Try to avoid putting multiple event structures in the same loop: you might have deadlocks that are hard to debug. Also, the use of local variables to keep information between loops

Instead of modifying your code, I thought I'd prepare a Login Demo project for you to look at. It's based on a queued state machine, for which you can find examples in LabVIEW's help or templates. I've put many comments in the code for helping you expand on this example. I hope you find that this demo is useful to decompose all your use cases and create a login VI with the desired functions. Try modifying this base code to achieve the list of specifications you have. If you still have questions, come back... ;-)

Login demo.zip (LV 2009)

Edited by Papang
Link to comment

It was really help me, but I'm still do not know how to create this:

  • When addbutton selected, add user panel will appear and display 2 empty string controlswhich username and password. To add other user, he/she just insertusername/password that they want, press add user button, those data will automaticallyinserted into the table and user admin will back to user panel.
  • When deletebutton selected, delete user panel will appear and display 2 empty stringcontrols which username and password. To delete other user, he/she just insertusername/password that they want, press delete user button, those data will automaticallydeleted from the table and user admin will back to user panel. ButIF username/password is not relevantwith table’s data, message box will appear (telling that username/passwordinserted are not available) and the string control will be empty.

Can you assist me?

I could, but at this point I'm not convinced this isn't an homework ("he/she" is usually indicative of a generic written question) , so I'd like to see that you start to implement these functions. When I tried to answer your question, I couldn't find a simple way to help with your existing program. Any suggestions I would have made would have added more complexity and bug potentials, so I opted to show you a design that you could build on. I hope the design is not too advanced because that would defeat my purpose here.

Ask yourself, what do I need to implement these two requisites? Are these just two more possible states to be added to my design? How can I add a state in my code?

  • Like 1
Link to comment

Actually I create these requirements by my own. My lecture not ask me for that but its better if I can implement those functions because my current program is add the user manually by typing into the table. Do you have any basic steps to implement function like I mention before? Forget about my previous program. Maybe I can combine it later.

I could, but at this point I'm not convinced this isn't an homework ("he/she" is usually indicative of a generic written question) , so I'd like to see that you start to implement these functions. When I tried to answer your question, I couldn't find a simple way to help with your existing program. Any suggestions I would have made would have added more complexity and bug potentials, so I opted to show you a design that you could build on. I hope the design is not too advanced because that would defeat my purpose here.

Ask yourself, what do I need to implement these two requisites? Are these just two more possible states to be added to my design? How can I add a state in my code?

Link to comment

Glad to hear it's not a homework.

To add or delete users from the database, you will have to have a file which contains you credentials.

Steps to implement:

1- Create a file that will contain the usernames, passwords (encrypted would be best...) and privileges. (You can "salt" your encryption

If your file will be small, load its content on initialization and store it in the Cluster from easy access.

If your file is to be deployed, create VIs to access the file throughout your program (call when needed).

2- Create a VI that will read the data from file and a VI that writes (or modifies) the data in file.

3- Add two states in the case structure for saving to file and reading from it. These states will be called when you have a logon (read) or add/delete user credentials (write).

4- Create two more states (add user / delete user) and associate the buttons for adding and deleting users in the Event structure to call these states when required. You will handle all the hiding/showing of controls in these states. These options will be revealed in the Login state if the user has logged in as an admin. If so, enqueue a new state to reveal the "Add user" and "Delete user" on the front panel.

5- In the Event structure (Idle state), associate the OK button from the delete or add users and call a sequence of states (using Queue VIs) to perform the necessary actions (Show/Hide stuff, read database, write to database, verification, etc.)

Try this and upload your modified code if you need more help.

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.