Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a two login types one is simpleuser and other is admin ...one admin is default admin he create accounts of other admins and he assign desginations and departments also

login code

C#
if (users == 1)
                {
                    Session["Login2"] = txt_username.Value;
                    Session["Login3"] = txt_pass.Value;

                    Session["UserTypeID"] = users;

                    Response.Redirect("AdminOp.aspx");
                }
                else if (users == 2)
                {

                    Session["Login2"] = txt_username.Value;
                    Session["Login3"] = txt_pass.Value;


                    Session["UserTypeID"] = users;

                    Response.Redirect("upload.aspx");
                }
            }           
        catch
        {
            Label8.Text = "Incorrect User Name or Password";
        }
    } 


1 is admin and 2 is user when supervsior is login to their account then he see menu where there is a options like this this is adminOp.aspx

C#
View Documents

            </span>
        </a>
    </li>
    <li>
        <a href="SuperVisor.aspx">
            <span>

                Approve Documents

            </span>
        </a>
    </li>



now when manager is login then how they access their page and able to see their menu because in above options there is only supervisor ...what about done this is manager?
Posted
Updated 8-Nov-13 6:34am
v2
Comments
When Manager logins, what is the value of "users" 1 or 2?
Diya Ayesa 8-Nov-13 14:16pm    
i mentioned it 1 is admin and 2 is user and manager login for approving/reject documents
Diya Ayesa 8-Nov-13 14:16pm    
where is manager is also admin
Then you have to check the designation again.

Get the user designation and compare like below...

If(userDesignation.ToUpper().Equals("MANAGER"))
{
// your code here...
}
Diya Ayesa 8-Nov-13 15:12pm    
where i done this??in login form?

1 solution

This code is not readable. Create a list of roles, and assign users to roles via a joining table. Make the enum a bit field, and store that in the session. Having '1 is managers' is an arcane rule that makes your code hard to maintain. Don't store the username and password in the session, why would you do that ? Use switch instead of if/then/else, and ideally switch on method calls, so your code is readable. Like this

switch(userType)
{
  case User.Admin:
     LoginAdmin(username, password);
     break;
  case User.Basic:
      LoginBasicUser(username, password);
      break;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900