public Boolean InsertNewUser(DynamoDBContext context, string userName, string userPassword, string userEmail, string userSalt) { Boolean insertedUser = false; IEnumerable<Users> usersFound = context.Scan<Users>(); int userID = 0; if (usersFound.LongCount() > 0) { Users lastRegistered = usersFound.OrderBy(dr => dr.UserID).Last(); if (lastRegistered != null) userID = lastRegistered.UserID + 1; else userID++; } else userID++; try { Users newUser = new Users(); newUser.UserID = userID; newUser.UserName = userName; newUser.UserPassword = userPassword; newUser.UserEmail = userEmail; newUser.UserSalt = userSalt; newUser.UserRegistered = false; context.Save<Users>(newUser); insertedUser = true; } catch (Exception ex) { insertedUser = false; } return insertedUser; }
protected Boolean PasswordsMatch(string typedPassword, Users user) { Boolean passwordsMatch = false; string salt = user.UserSalt; string pepper = "aPepper21"; string hashedPassword = GetSH1(user.UserName + typedPassword + salt); string pepperedPassword = GetSH1(hashedPassword + user.UserName + pepper); if (pepperedPassword == user.UserPassword) passwordsMatch = true; return passwordsMatch; }