private static int tryLogin(string email, string password) { renoRatorDBEntities _db = new renoRatorDBEntities(); var user = _db.Users.Where(u => u.email == email).FirstOrDefault(); if (user != null && user.password == PasswordFunctions.CreateHash(password, user.salt)) { return(user.userID); } return(-1); }
public void Save() { var db = new renoRatorDBEntities(); User newUser = new User(); newUser.userTypeID = this.userTypeID; newUser.fname = this.fname; newUser.lname = this.lname; newUser.email = this.email; newUser.password = this.password; if (!String.IsNullOrEmpty(this.bio)) { newUser.bio = this.bio; } if (this.profileGalleryID > 0) { newUser.profileGalleryID = this.profileGalleryID; } if (this.profilePhotoID > 0) { newUser.profilePhotoID = this.profilePhotoID; } if (this.addressID > 0) { newUser.addressID = this.addressID; } if (this.portfolioGalleryID > 0) { newUser.portfolioGalleryID = this.portfolioGalleryID; } // salt and hash the password string salt = PasswordFunctions.CreateSalt(8); newUser.salt = salt; newUser.password = PasswordFunctions.CreateHash(newUser.password, salt); db.AddToUsers(newUser); db.SaveChanges(); }