Skip to Content
0
Former Member
Jan 26, 2007 at 09:08 AM

user management -logic thinking

12 Views

currently , i have many users to be managed in user management...

i set up my webydnpro to authenticated the user,

i will based on the user role and then restricted the access to the application,

can view only their department stuff...

let's say a 5 department , i categorized into

hr_admin hr_normal_user,hr_super_user
sales_admin, sales_normal_user, sales_super_user,
................
enterprise_super_user (can view all department info)

what i do is basically many if and else statement...and many hardcode

can anyone proposed a better solution for this.....

String user_role=new String();
	while(rit.hasNext()){
		String roleName=(String) rit.next();
		IRole role=rfact.getRole(roleName);
		user_role=role.getDisplayName();
		
	//check role
	if(user_role.equalsIgnoreCase("hr_ADMIN")){
		role_hr_ADMIN=true;
	}else if(user_role.equalsIgnoreCase("hr_NORMAL_USER")){
		role_hr_NORMAL_USER=true;
	}else if(user_role.equalsIgnoreCase("hr_SUPER_USER")){
		role_hr_SUPER_USER=true;
	}

this is troublesome...any suggestion....

if i going to make this if ...else..to switch ..how can i do that...

switch(user_role){        //error >> >>>in side switch cannot be String
case hr_ADMIN: 
       role_hr_ADMIN=true;
       break;
case hr_NORMAL_USER;
       role_hr_NORMAL_USER=true;
       break;
}