public bool GrantAccess(string username, string passwordTry) { Member member = Members.Where(m => m.Username == username).FirstOrDefault(); if (member != null) { string CryptoSalt = member.CryptoSalt; // From database string CryptoPassword = member.CryptoPassword; // From database string CryptoPasswordToCheck = cryptoHelpers.EncryptWithPBKDF2(passwordTry, CryptoSalt); if (CryptoPassword == CryptoPasswordToCheck) { return(true); } } return(false); }
public Tuple <string, Member> Login(LoginModel loginModel) //Returns JWT token with member or null for any errors, note: If user enters the password correct then generate JiWT, otherwise return null. { if (loginModel == null) { return(null); } Member member = Members.Where(m => m.Username == loginModel.Username).FirstOrDefault(); if (member != null) { string LoginPassword = loginModel.Password; // From user login UI string CryptoSalt = member.CryptoSalt; // From database string CryptoPassword = member.CryptoPassword; // From database string CryptoPasswordToCheck = cryptoHelpers.EncryptWithPBKDF2(LoginPassword, CryptoSalt); if (CryptoPassword == CryptoPasswordToCheck) { //return jwtHelpers.GenerateJWT(loginModel.Username); // Send a valid JWT to our member return(new Tuple <string, Member>(jwtHelpers.GenerateJWT(loginModel.Username), member)); } } return(null); }