예제 #1
0
        public async Task <IActionResult> Verify(long id, string vcode)
        {
            if (string.IsNullOrEmpty(vcode))
            {
                throw new BadRequestException("Bad request. PLease try again");
            }

            var udetails = await _userService.Get(id);

            if (udetails == null)
            {
                throw new BadRequestException("Verification details is invalid");
            }

            VerificationDetailModel vdetails = await _verificationService.Get(vcode);

            if (vdetails == null)
            {
                throw new BadRequestException($"Verification link is invalid");
            }
            if (vdetails.IsVerified)
            {
                throw new BadRequestException($"Verification link has been used");
            }
            udetails.userStatus = UserStatus.ACTIVE;

            bool result = await _userService.UpdateStatus(udetails);

            if (result)
            {
                await _verificationService.InValidateCode(vcode, id.ToString());

                return(Ok(new ResponseModel()
                {
                    code = ResponseCode.SUCCESSFULL,
                    description = "Verification is successful"
                }));
            }
            else
            {
                throw new BadRequestException("Verification process failed. Please try again or contact your administrator");
            }
        }