Papang Posted September 22, 2010 Report Share Posted September 22, 2010 Hi lavas, I was creating a user login system using usernameand password, but there something less with the functions. Here belowdescription of the system. User should using an admin account (username:admin/password:123456)to login at the first time. When the user was login and stand as adminposition, user panel will appear and display 3 buttons which add, delete and view. 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. 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. 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. 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. 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. Thank you. Quote Link to comment
Papang Posted September 22, 2010 Author Report Share Posted September 22, 2010 Here is my basic program. Please review it. Thank you. Authentication.vi Quote Link to comment
Francois Normandin Posted September 22, 2010 Report Share Posted September 22, 2010 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) 1 Quote Link to comment
Papang Posted September 23, 2010 Author Report Share Posted September 23, 2010 (edited) 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 September 23, 2010 by Papang Quote Link to comment
Francois Normandin Posted September 23, 2010 Report Share Posted September 23, 2010 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? 1 Quote Link to comment
Papang Posted September 23, 2010 Author Report Share Posted September 23, 2010 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? Quote Link to comment
Francois Normandin Posted September 23, 2010 Report Share Posted September 23, 2010 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. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.