// Login public async Task <LoginResult> LoginAsync(string username, string password) { var user = await _persistence.Users.GetByUsernameAsync(username); if (user == null) { return(LoginResult.GetFailed()); } var auth = (await _persistence.UserAuthentications.GetByUserAsync(CredentialType.PasswordHash, user.Id)) .SingleOrDefault(); if (!BCrypt.Net.BCrypt.Verify(password, auth.Secret)) { return(LoginResult.GetFailed()); } // add validation that user is allowed to login // add in option of for multifactor and use options to provide redirect url await SignInAsync(user); return(LoginResult.GetSuccess()); }
public async Task <LoginResult> LoginExternalAsync(CredentialType credentialType, string identity) { var user = await _persistence.UserAuthentications.GetBySecretAsync(credentialType, identity); if (user == null) { return(LoginResult.GetFailed()); } // add validation that user is allowed to login // add in option of for multifactor and use options to provide redirect url await SignInAsync(user); return(LoginResult.GetSuccess()); }
public async Task <LoginResult> LoginAsync(string userName, string password) { var user = await _userRepository.GetUserByUsernameAsync(userName); if (user == null) { return(LoginResult.GetFailed()); } if (!BCrypt.Net.BCrypt.Verify(password, user.PasswordHash)) { return(LoginResult.GetFailed()); } await SignInAsync(user); return(LoginResult.GetSuccess()); }
public async Task <LoginResult> LoginExternalAsync(string scheme, string identity) { var authScheme = StringToScheme(scheme); var user = await _persistence.Users.GetUserByAuthenticationAsync(authScheme, identity); if (user == null) { return(LoginResult.GetFailed()); } // add validation that user is allowed to login // add in option of for multifactor and use options to provide redirect url await SignInAsync(user); return(LoginResult.GetSuccess()); }
public async Task <LoginResult> LoginAsync(string userName, string password) { var user = await _persistence.Users.GetUserByUsernameAsync(userName); if (user == null) { return(LoginResult.GetFailed()); } if (!BCrypt.Net.BCrypt.Verify(password, user.PasswordHash)) { return(LoginResult.GetFailed()); } // add validation that user is allowed to login // add in option of for multifactor and use options to provide redirect url await SignInAsync(user); return(LoginResult.GetSuccess()); }