/// <summary> /// Скидання паролю користувача /// </summary> /// <param name="clientId">Id клієнта Monobank</param> /// <returns>[Стан] Пароль скинуто / не скинуто та згенерований пароль для користувача</returns> public static async Task <(bool isResetCompleted, string newPassword)> ResetPasswordAsync(string clientId) { await using var db = new MonoboardDbContext(); var user = await db.MonoBoardUsers.FirstAsync(monoboardUser => monoboardUser.ClientId == clientId); var newPassword = Sha256Hash.Compute($"user{user.ClientId}!"); bool isComplete; if (user.Password != newPassword) { user.Password = newPassword; user.IsPasswordReset = true; isComplete = await db.SaveChangesAsync() > 0; } else { isComplete = true; } return(isComplete, $"user{user.MonoboardUserKey}{user.ClientId}!"); }