/// <summary> /// Create a new User object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="username">Initial value of the Username property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="passwordSalt">Initial value of the PasswordSalt property.</param> /// <param name="secretQuestion">Initial value of the SecretQuestion property.</param> /// <param name="secretAnswer">Initial value of the SecretAnswer property.</param> /// <param name="created">Initial value of the Created property.</param> public static User CreateUser(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String username, global::System.String password, global::System.String passwordSalt, global::System.String secretQuestion, global::System.String secretAnswer, global::System.DateTime created) { User user = new User(); user.ID = id; user.FirstName = firstName; user.LastName = lastName; user.Username = username; user.Password = password; user.PasswordSalt = passwordSalt; user.SecretQuestion = secretQuestion; user.SecretAnswer = secretAnswer; user.Created = created; return user; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
public ActionResult Index(User login) { string user = login.Username; if (repo.CheckUserExist(user)) { int userID = repo.GetUserID(user); string db_saltHashed = repo.GetSaltHashedPassword(userID); string db_salt = repo.GetSalt(userID); SaltHashPassword shp = new SaltHashPassword(); string password = login.Password; string saltHashed = db_salt + shp.GetHashedPassword(password); // check if password is correct if (saltHashed == db_saltHashed) { Session["Username"] = user; Session["UserID"] = userID; return RedirectToAction("Create", "Admin"); } else { Session["Message"] = "Password Incorrect!"; return RedirectToAction("Index", "Admin"); } } Session["Message"] = "Username does not exist!"; return RedirectToAction("Index", "Admin"); }
/// <summary> /// Add a new user /// </summary> /// <param name="user">User class</param> public void AddNewUser(User user) { dbase.Users.AddObject(user); }
public ActionResult Index() { if (Session["Username"] != null) return RedirectToAction("Create", "Admin"); User user = new User(); return View(user); }