java - Creating muti user access login form -
i have created login form system have created. have 1 user access login meaning 1 login whole system. here want , want have multiple user logins such doctor , nurse , admin . there should restrictions well, such if user logged in doctor or nurse, user can view details , else if user has logged in admin , user can access part in system.
here have done far:-
private void btnenteractionperformed(java.awt.event.actionevent evt) { string password=new string (txtpassword.getpassword()); //method password password field string username=txtusername.gettext(); if(username.equals("admin") && password.equals("admin123")) { joptionpane.showmessagedialog(frame,"welcome system","welcome",joptionpane.information_message); main_menu enter=new main_menu(); enter.setvisible(true); close(); } else { joptionpane.showmessagedialog(frame,"wrong username/password","invalid username or password",joptionpane.error_message); } }
i can use same method give different access logins cannot set access level user, except going each , every form in system , using "if" condition , restricting user access level. isn't effective enough me, there other method in simpler way ?
thank time
i believe create authentication function, , call anywhere user needed authenticate. alternately, it's common group of restricted functions set of restricted pages, , call authentication when page loaded, don't have verify on each , every form. 1 of common methods through cookies. when user logs in, set cookie them. restricted pages call check make sure user has cookie, , if don't, redirected login page.
i'm not java developer couldn't tell code be, believe that's standard mo in php, , know many sites set cookies javascript (much dismay).
Comments
Post a Comment