public async Task <bool> RestPasswordWithOldAsync(string connectId, string userName, string old, string @new) { var privateKey = await GetPrivateKeyAsync(connectId); if (privateKey is null) { return(false); } var pwdOld = RSAHelper.RSADecrypt(privateKey, old); if (string.IsNullOrEmpty(pwdOld)) { return(false); } var pwdNew = RSAHelper.RSADecrypt(privateKey, @new); if (string.IsNullOrEmpty(pwdNew)) { return(false); } var user = new AnfUser { UserName = userName }; var ok = await userManager.ChangePasswordAsync(user, pwdOld, pwdNew); return(ok.Succeeded); }
public Task <string> GenerateResetTokenAsync(string userName) { var user = new AnfUser { UserName = userName }; return(userManager.GeneratePasswordResetTokenAsync(user)); }
public async Task <bool> RegisteAsync(string connectId, string userName, string passwordHash) { var pwd = await DecryptAsync(connectId, passwordHash); if (string.IsNullOrEmpty(pwd)) { return(false); } var user = new AnfUser { UserName = userName }; var identity = await userManager.CreateAsync(user, pwd); return(identity.Succeeded); }
public async Task <bool> RestPasswordAsync(string connectId, string userName, string resetToken, string @new) { var pwdNew = await DecryptAsync(connectId, @new); if (string.IsNullOrEmpty(pwdNew)) { return(false); } var user = new AnfUser { UserName = userName }; var ok = await userManager.ResetPasswordAsync(user, resetToken, pwdNew); return(ok.Succeeded); }