Пример #1
0
        /// <summary>
        /// Sets a flag indicating whether the specified <paramref name="user"/> has two factor authentication enabled or not,
        /// as an asynchronous operation.
        /// </summary>
        /// <param name="user">The user whose two factor authentication enabled status should be set.</param>
        /// <param name="enabled">A flag indicating whether the specified <paramref name="user"/> has two factor authentication enabled.</param>
        /// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
        public virtual async Task SetTwoFactorEnabledAsync(TUser user, bool enabled, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            // TODO: Pass in parameter to enable setting up software token and/or sms

            var request = new AdminSetUserMFAPreferenceRequest
            {
                Username   = user.Username,
                UserPoolId = _pool.PoolID,
                SoftwareTokenMfaSettings = new SoftwareTokenMfaSettingsType
                {
                    PreferredMfa = enabled,
                    Enabled      = enabled
                }
            };

            try
            {
                var result = await _cognitoClient.AdminSetUserMFAPreferenceAsync(request, cancellationToken)
                             .ConfigureAwait(false);
            }
            catch (AmazonCognitoIdentityProviderException e)
            {
                throw new CognitoServiceException("Failed to set 2FA settings for the Cognito User", e);
            }
        }
 public void AdminSetUserMFAPreferenceAsync(AdminSetUserMFAPreferenceRequest request, AmazonServiceCallback <AdminSetUserMFAPreferenceRequest, AdminSetUserMFAPreferenceResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }