Esempio n. 1
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         if (Membership.ValidateUser(txtUserName.Text, txtPassWord.Text))
         {
             if (!string.IsNullOrEmpty(UserPermission.GetWebPermission(txtUserName.Text)) || Common.isAdminAccount(txtUserName.Text))
                 FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, cbRememberMe.Checked ? true : false);
             else
             {
                 lblLoginFail.Visible = true;
                 lblLoginFail.Text = GetResource("msPermission");
                 return;
             }
         }
         else
         {
             lblLoginFail.Visible = true;
             lblLoginFail.Text = GetResource("LoginFail");
         }
     }
     catch (Exception ex)
     {
         logger.Error("Error Login", ex);
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert(\"" + GetJSMessage(GetResource("Title_Error.Text"), ex.Message) + "\");", true);
     }
 }
Esempio n. 2
0
 public List <Machine> GetListMachineFromUser(string userName, string password)
 {
     try
     {
         if (Membership.ValidateUser(userName, password))
         {
             if (UserPermission.GetWebPermission(userName) != "")
             {
                 List <Machine> list = Machine.GetListMachineFromUser(userName);
                 if (list == null)
                 {
                     throw new Exception("This user dosen't have permission to access !");
                 }
                 else
                 {
                     return(list);
                 }
             }
             else
             {
                 throw new Exception("This user dosen't have permission to access !");
             }
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }