public string ReturnUsername() { try { return(QuToolsUtilities.GetSession("QToolsUser")); } catch { return("None"); } }
} //end of checkAdmin() public AccountManagerViewModel CheckUser(AccountManagerViewModel user) { AccountManagerViewModel myConn = user; string sqlCmd; try { using (SqlConnection connection = new SqlConnection(QuToolsUtilities.GetConnectionString("internet"))) //ConfigurationExtensions.GetConnectionString(ConfigurationString, "internet"))) { connection.Open(); string username = QuToolsUtilities.GetSession("QUToolsUser"); // HttpContext.Session.GetString("QUToolsUser"); // HttpContext.Current.Session["QUToolsUser"].ToString(); sqlCmd = "select * from {0} where QU_User = @qun"; sqlCmd = String.Format(sqlCmd, user.UserTable); SqlCommand command = new SqlCommand(sqlCmd, connection); command.Parameters.AddWithValue("@qun", user.Username); //command.Parameters.AddWithValue("@db", User.userTable); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { if (reader["QU_User"].ToString() == username && reader["toolAdmin"].ToString() == "N") { myConn.Admin = "No"; myConn.Username = username; myConn.Userlevel = reader["userlevel"].ToString(); return(myConn); } else { myConn.Admin = "Yes"; myConn.Username = username; myConn.Userlevel = reader["userlevel"].ToString(); return(myConn); } } } connection.Close(); } } catch (Exception e) { myConn.ReturnMsg = e.Message; return(myConn); } return(myConn); } //end of checkUser()
public bool CheckSession() { try { if (QuToolsUtilities.GetSession("QTools") != HashIt(QuToolsUtilities.GetSession("QTools"), "xx44aaAAddDDffDDeeEEe")) { return(true); } else { return(false); } } catch { return(false); } }