public async Task <VerifyExternalLoginWhenAccountIsExistModel> VerifyExternalLoginWhenAccountIsExist(VerifyExternalLoginWhenAccountIsExistModel model) { try { var page = await base.InitPage(); model.SetInitInfo(page); RVerify verify = await _emailSmsService.GetVerifyFromDb(model.VerifyId); if (verify == null) { model.AddMessage(ResourceKey.Verify_NotExist); return(model); } if (verify.CheckStatus(EnumDefine.VerifyStatusEnum.Used)) { model.AddMessage(ResourceKey.Verify_Used); return(model); } if (verify.CheckStatus(EnumDefine.VerifyStatusEnum.Cancel)) { model.AddMessage(ResourceKey.Verify_Cancel); return(model); } if (verify.ExpireDate < Extensions.GetCurrentDateUtc()) { model.AddMessage(ResourceKey.Verify_Expired); return(model); } RijndaelSimple rijndaelSimple = new RijndaelSimple(); string verifyCode; try { string code = UnicodeUtility.FromHexString(model.VerifyCode); verifyCode = rijndaelSimple.Decrypt(code, verify.SaltKey); } catch (Exception e) { model.AddMessage(ResourceKey.Verify_CodeNotExact); return(model); } if (verify.VerifyCode != verifyCode) { model.AddMessage(ResourceKey.Verify_CodeNotExact); return(model); } ActiveCodeWhenAccountIsExistModel activeCodeWhenAccountIsExistModel = verify.GetModel <ActiveCodeWhenAccountIsExistModel>(); var customer = await _customerService.GetFromDb(activeCodeWhenAccountIsExistModel.CustomerId); CustomerExternalLoginAddCommand command = new CustomerExternalLoginAddCommand() { LoginProvider = activeCodeWhenAccountIsExistModel.LoginProvider, ProviderKey = activeCodeWhenAccountIsExistModel.ProviderKey, ProviderDisplayName = activeCodeWhenAccountIsExistModel.LoginProvider.ToString(), CustomerId = activeCodeWhenAccountIsExistModel.CustomerId, Info = activeCodeWhenAccountIsExistModel.Info, VerifyId = verify.Id, Version = customer.Version }; var result = await _customerService.SendCommand(command); if (!result.IsSucess) { model.AddMessage(result.Message); } return(model); } catch (Exception e) { _logger.LogError(e, e.Message); throw e; } }