/// <summary>
        /// Updates the device status to not be remembered using an asynchronous call
        /// </summary>
        public Task DoNotRememberThisDeviceAsync()
        {
            UpdateDeviceStatusRequest updateRequest =
                CreateUpdateDeviceStatusRequest(new DeviceRememberedStatusType(CognitoConstants.DeviceAttrNotRemembered));

            return(User.Provider.UpdateDeviceStatusAsync(updateRequest));
        }
        /// <summary>
        /// Updates the device status to not be remembered using an asynchronous call
        /// </summary>
        public void DoNotRememberThisDeviceAsync(AsyncCallback callback = null)
        {
            UpdateDeviceStatusRequest updateRequest =
                CreateUpdateDeviceStatusRequest(new DeviceRememberedStatusType(CognitoConstants.DeviceAttrNotRemembered));

            User.Provider.UpdateDeviceStatusAsync(updateRequest, r =>
            {
                callback?.Invoke(new AsyncResult(r.Exception));
            });
        }
Example #3
0
        /// <summary>
        /// Updates the remembered status for a given CognitoDevice
        /// </summary>
        /// <param name="accessToken">The user pool access token for from the InitiateAuth or other challenge response</param>
        /// <param name="deviceKey">The device key for the associated CognitoDevice</param>
        /// <param name="deviceRememberedStatus">The device remembered status for the associated CognitoDevice</param>
        /// <returns></returns>
        public async Task <UpdateDeviceStatusResponse> UpdateDeviceStatusAsync(string accessToken, string deviceKey, string deviceRememberedStatus)
        {
            var request = new UpdateDeviceStatusRequest
            {
                AccessToken            = accessToken,
                DeviceKey              = deviceKey,
                DeviceRememberedStatus = deviceRememberedStatus
            };

            return(await Provider.UpdateDeviceStatusAsync(request));
        }
        private UpdateDeviceStatusRequest CreateUpdateDeviceStatusRequest(DeviceRememberedStatusType deviceRememberedStatus)
        {
            if (User.SessionTokens == null || !User.SessionTokens.IsValid())
            {
                throw new NotAuthorizedException("User is not authorized.");
            }

            var updateDeviceStatusRequest = new UpdateDeviceStatusRequest()
            {
                AccessToken            = User.SessionTokens.AccessToken,
                DeviceKey              = DeviceKey,
                DeviceRememberedStatus = deviceRememberedStatus
            };

            return(updateDeviceStatusRequest);
        }
        /// <summary>
        /// Update status for cognito device
        /// </summary>
        /// <param name="deviceStatus">The device remembered status for the associated CognitoDevice</param>
        /// <returns></returns>
        public async Task <UpdateDeviceStatusResponse> UpdateDeviceStatusAsync(string deviceStatus)
        {
            EnsureUserAuthenticated();
            if (string.IsNullOrWhiteSpace(deviceStatus))
            {
                throw new ArgumentNullException(nameof(deviceStatus));
            }
            if (Device == null)
            {
                throw new Exception($"{Device} is null at {nameof(CognitoUser)}");
            }

            var request = new UpdateDeviceStatusRequest
            {
                AccessToken            = SessionTokens.AccessToken,
                DeviceKey              = Device.DeviceKey,
                DeviceRememberedStatus = deviceStatus
            };

            return(await Provider.UpdateDeviceStatusAsync(request).ConfigureAwait(false));
        }
 public void UpdateDeviceStatusAsync(UpdateDeviceStatusRequest request, AmazonServiceCallback <UpdateDeviceStatusRequest, UpdateDeviceStatusResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }