private bool authenticated(string loginID, string password) { try { var ds = AdminUserModel.getUser(loginID); if (ds.Tables[0].Rows.Count > 0) { string passwordstring = ds.Tables[0].Rows[0]["password"].ToString(); if (password.Equals(passwordstring.Trim())) { _currentUser.ID = ((int)ds.Tables[0].Rows[0]["ID"]); _currentUser.password = ((string)ds.Tables[0].Rows[0]["password"]).Trim(); _currentUser.name = ((string)ds.Tables[0].Rows[0]["name"]).Trim(); _currentUser.email = ((string)ds.Tables[0].Rows[0]["email"]).Trim(); _currentUser.role = ((string)ds.Tables[0].Rows[0]["role"]).Trim(); _currentUser.loginID = ((string)ds.Tables[0].Rows[0]["login_ID"]).Trim(); Session[AllConstStrs.se_currentUser] = _currentUser; return(true); } } return(false); } catch { return(false); } }
public static bool ValidateInputs(ref BulletedList bl_errors, ref User newUser, ref TextBox tb_userName, ref TextBox tb_name, ref TextBox tb_email, ref TextBox tb_password, ref TextBox tb_confpassword, ref RadioButtonList rbl_role, bool checkUsername) { bl_errors = new BulletedList(); bool result = true; newUser.loginID = HttpContext.Current.Server.HtmlEncode(tb_userName.Text.Trim()); newUser.name = HttpContext.Current.Server.HtmlEncode(tb_name.Text.Trim()); newUser.email = HttpContext.Current.Server.HtmlEncode(tb_email.Text.Trim()); newUser.role = HttpContext.Current.Server.HtmlEncode(rbl_role.SelectedValue.Trim()); string confPass = HttpContext.Current.Server.HtmlEncode(tb_confpassword.Text.Trim()); newUser.password = HttpContext.Current.Server.HtmlEncode(tb_password.Text.Trim()); if (String.IsNullOrEmpty(newUser.loginID)) { bl_errors.Items.Add(new ListItem(AllConstStrs.LoginID_Empty)); result = false; } if (!String.IsNullOrEmpty(newUser.password)) { //if (String.IsNullOrEmpty(newUser.password)) //{ // bl_errors.Items.Add(new ListItem(AllConstStrs.Pass_Empthy)); // result = false; //} if (!Regex.IsMatch(newUser.password, AllConstStrs.regx_Password2)) { bl_errors.Items.Add(new ListItem(AllConstStrs.Pass2_Hint)); result = false; } //if (newUser.password.Contains(newUser.loginID.ToLower())) //{ // bl_errors.Items.Add(new ListItem(AllConstStrs.Pass_Has_Username)); // result = false; //} if (newUser.password != confPass) { bl_errors.Items.Add(new ListItem(AllConstStrs.Password_Conf_Mismatch)); result = false; } } if (String.IsNullOrEmpty(newUser.role)) { bl_errors.Items.Add(new ListItem(AllConstStrs.Role_Empthy)); result = false; } //return upto here if (result == false) { return(result); } if (checkUsername) { if (AdminUserModel.getUser(newUser.loginID).Tables[0].Rows.Count > 0) { bl_errors.Items.Add(new ListItem(AllConstStrs.Dup_Username)); result = false; } } //if (!Regex.IsMatch(newUser.name, AllConstStrs.regx_Name)) //{ // bl_errors.Items.Add(new ListItem(AllConstStrs.Name_Hint)); // result = false; //} return(result); }