Demo: Verify Password

In the Conduit.Repositories Project

Fix the incorrect user reference
  • Rename the parameter user to login
  • Find all instances of the variable and rename them
  • Caution: leave the user variable that is being return to the calling Controller method
Generate the VerifyPassword method
  • Hover over the error
  • Select [Generate method]
Implement the VerifyPassword method
  • Options for implementing:
    • Preview video
    • Preview finished code below

Here is the code for the VerifyPassword Method:

        private bool VerifyPassword(string password, byte[] passwordHash, byte[] passwordSalt)
            using (var hmac = new HMACSHA512(passwordSalt))
                var computedHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(password));
                for (int i = 0; i < computedHash.Length; i++)
                    if (computedHash[i] != passwordHash[i])
                        return false;
                return true;

Conduit Github Repo

Tag Name: working-login-api