public bool AuthUser(string userName, string password) { var auth = false; if (DoesUserEmailExists(userName)) { var chyptographyHelper = new CryptographyHelper(); var passhwordHash = chyptographyHelper.SHA256Hasher(password); _lockUserLoginDictionary.EnterReadLock(); auth = UserLoginDictionary[userName] == passhwordHash; _lockUserLoginDictionary.ExitReadLock(); } return auth; }
private static void AddUser(string preferredName, string surname, string email, string password, DateTime birthday, string gender, bool isActive, MembershipDB context) { var chyptographyHelper = new CryptographyHelper(); var passhwordHash = chyptographyHelper.SHA256Hasher(password); context.Users.Add(new User { UserType = context.UserTypes.First(x => x.Name == "Client"), Gender = context.Genders.First(x => x.Name == gender.Trim()), Email = email.Trim(), PasswordHash = passhwordHash, Names = string.Format("{0} {1}", preferredName, surname), LastName = surname.Trim(), PreferredName = preferredName.Trim(), IsActive = isActive, Birthday = birthday, Comment = string.Empty, UpdatedOn = DateTime.Now, CreatedOn = DateTime.Now, LastUpdatedBy = 1 }); }