public async Task <ConfirnmationResponse> ConfirmEmailAsync(ConfirnmationRequest request)
        {
            try
            {
                var confirmCode = ConfirmationCode.Generate();
                var sent        = await SendAndStoreConfirmationCode(confirmCode, request.Email);

                if (!sent)
                {
                    return new ConfirnmationResponse
                           {
                               Status = new APIResponseStatus
                               {
                                   IsSuccessful = false,
                                   Message      = new APIResponseMessage
                                   {
                                       FriendlyMessage = "Unable to send mail!! please contact systems administrator"
                                   }
                               }
                           }
                }
                ;

                return(new ConfirnmationResponse
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = true,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Please Check your email for email for confirnmation"
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                #region Log error
                var errorCode = ErrorID.Generate(4);
                _logger.Error($"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}");
                return(new ConfirnmationResponse
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = false,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Error occured!! Please tyr again later",
                            MessageId = errorCode,
                            TechnicalMessage = $"ErrorID : {errorCode} Ex : {ex?.Message ?? ex?.InnerException?.Message} ErrorStack : {ex?.StackTrace}"
                        }
                    }
                });

                #endregion
            }
        }
示例#2
0
        public async Task <IActionResult> ConfirmationCode([FromBody] ConfirnmationRequest request)
        {
            var userExist = await _identityService.CustomerVerifyAsync(request.Email, request.Code);

            if (!userExist.Status.IsSuccessful)
            {
                return(BadRequest(new ConfirnmationResponse
                {
                    Status = userExist.Status
                }));
            }
            return(Ok(new ConfirnmationResponse
            {
                Email = request.Email,
                Status = new APIResponseStatus
                {
                    IsSuccessful = true,
                }
            }));
        }
示例#3
0
        public async Task <IActionResult> ConfirmationCode([FromBody] ConfirnmationRequest request)
        {
            if (request.Code.Length < 4)
            {
                return(BadRequest(new ConfirnmationResponse
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = false,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = "Invalid Verification Code"
                        }
                    }
                }));
            }

            var userExist = await _identityService.VerifyAsync(request.Email);

            if (!userExist.Status.IsSuccessful)
            {
                return(BadRequest(new ConfirnmationResponse
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = false,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = userExist.Status.Message.FriendlyMessage
                        }
                    }
                }));
            }
            return(Ok(new ConfirnmationResponse
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = true
                }
            }));
        }
示例#4
0
        public async Task <IActionResult> ConfirmEmail([FromBody] ConfirnmationRequest request)
        {
            try
            {
                if (request.Email.Length < 1)
                {
                    return(BadRequest(new ConfirnmationResponse
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = "Email Required change password"
                            }
                        }
                    }));
                }


                var userExist = await _identityService.CheckUserAsync(request.Email);

                if (!userExist)
                {
                    return(BadRequest(new ConfirnmationResponse
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = "Email not found"
                            }
                        }
                    }));
                }
                var response = await _identityService.ConfirmEmailAsync(request);

                if (!response.Status.IsSuccessful)
                {
                    return(BadRequest(new ConfirnmationResponse
                    {
                        Status = new APIResponseStatus
                        {
                            IsSuccessful = false,
                            Message = new APIResponseMessage
                            {
                                FriendlyMessage = response.Status.Message.FriendlyMessage
                            }
                        }
                    }));
                }
                return(Ok(new ConfirnmationResponse
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = true
                    }
                }));
            }
            catch (Exception ex)
            {
                _loggerService.Error(ex.Message ?? ex.InnerException.Message);
                return(BadRequest(ex.Message ?? ex.InnerException.Message));
            }
        }