/**
         * Set user address.
         */
        private async Task <APIGatewayProxyResponse> ResendEmailVerification(IDataStores dataStores,
                                                                             JObject requestBody)
        {
            Debug.Untested();
            Debug.AssertValid(dataStores);
            Debug.AssertValidOrNull(requestBody);

            try {
                // Log call
                LoggingHelper.LogMessage($"UserIdentityService::ResendEmailVerification()");

                // Get the NoSQL DB client
                AmazonDynamoDBClient dbClient = (AmazonDynamoDBClient)dataStores.GetNoSQLDataStore().GetDBClient();
                Debug.AssertValid(dbClient);

                // Check inputs
                ResendEmailVerificationRequest resendEmailVerificationRequest = UserIdentityService_ResendEmailVerification_LogicLayer.CheckValidResendEmailVerificationRequest(requestBody);
                Debug.AssertValid(resendEmailVerificationRequest);

                // Perform logic
                await UserIdentityService_ResendEmailVerification_LogicLayer.ResendEmailVerification(dbClient, resendEmailVerificationRequest);

                // Respond
                return(new APIGatewayProxyResponse {
                    StatusCode = APIHelper.STATUS_CODE_NO_CONTENT
                });
            } catch (Exception exception) {
                Debug.Tested();
                return(APIHelper.ResponseFromException(exception));
            }
        }
Пример #2
0
        /**
         * Resend email verification.
         */
        public static async Task ResendEmailVerification(AmazonDynamoDBClient dbClient, ResendEmailVerificationRequest resendEmailVerificationRequest)
        {
            Debug.Tested();
            Debug.AssertValid(dbClient);
            Debug.AssertValid(resendEmailVerificationRequest);
            Debug.AssertString(resendEmailVerificationRequest.emailAddress);

            // Find the user by email address
            User user = await IdentityServiceDataLayer.FindUserByEmailAddress(dbClient, resendEmailVerificationRequest.emailAddress);

            Debug.AssertValidOrNull(user);
            if (user != null)
            {
                // User exists
                Debug.AssertID(user.ID);
                if (user.EmailAddressVerified == null)
                {
                    Debug.Tested();
                    await DoResendEmailVerification(dbClient, user);
                }
                else if (user.NewEmailAddress != null)
                {
                    Debug.Tested();
                    await DoResendEmailVerification(dbClient, user);
                }
                else
                {
                    Debug.Untested();
                    throw new Exception(IdentityServiceLogicLayer.ERROR_EMAIL_ALREADY_VERIFIED, new Exception(IdentityServiceLogicLayer.EMAIL_ALREADY_VERIFIED));
                }
            }
            else
            {
                Debug.Tested();
                throw new Exception(SharedLogicLayer.ERROR_UNRECOGNIZED_EMAIL_ADDRESS, new Exception(SharedLogicLayer.ERROR_UNRECOGNIZED_EMAIL_ADDRESS));
            }
        }