Example #1
0
 private void SetContent(EmailOrSmsBaseCommand command)
 {
     switch (Type)
     {
     case EnumDefine.EmailOrSmsTypeEnum.ExternalLoginConfirmWhenAccountIsExist:
     {
         Content = Verify.VerifyUrl;
     }
     break;
     }
 }
Example #2
0
        public async Task <SendActiveCodeWhenAccountIsExistModel> SendActiveCodeWhenAccountIsExist()
        {
            try
            {
                SendActiveCodeWhenAccountIsExistModel model = new SendActiveCodeWhenAccountIsExistModel();
                var page = await base.InitPage();

                model.SetInitInfo(page);
                var user = _currentContext.HttpContext.User;
                if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated))
                {
                    model.AddMessage(ResourceKey.Account_ExternalLoginCallback_Fail);
                    return(model);
                }
                var identifier = user.FindFirst(p => p.Type == ClaimTypes.NameIdentifier)?.Value.Trim();
                var email      = user.FindFirst(p => p.Type == ClaimTypes.Email)?.Value.Trim();
                var res        = (EnumDefine.CutomerExternalLoginProviderEnum)Enum.Parse(typeof(EnumDefine.CutomerExternalLoginProviderEnum), user.Identity.AuthenticationType);
                model.EmailOrMobile = email;
                var customer = await _customerService.GetFromDbByEmailOrMobile(email);

                var messageType = string.IsNullOrEmpty(model.Email) ? EnumDefine.EmailOrSmsMessageTypeEnum.Sms : EnumDefine.EmailOrSmsMessageTypeEnum.Email;
                EmailOrSmsBaseCommand command = new EmailOrSmsBaseCommand(EnumDefine.EmailOrSmsTypeEnum.ExternalLoginConfirmWhenAccountIsExist, messageType, model.Mobile, model.Email)
                {
                    VerifyAddCommand = new VerifyAddCommand(TimeSpan.FromDays(2), EnumDefine.VerifyTypeEnum.EmailUrl, new ActiveCodeWhenAccountIsExistModel(customer.Id, res, identifier, string.Empty)),
                    Model            = new TestEmailSmsModel()
                    {
                        Name = "Tàu sân bay Mỹ neo đậu ở vịnh Đà Nẵng",
                        Url  = "https://vnexpress.net/tin-tuc/thoi-su/tau-san-bay-my-neo-dau-o-vinh-da-nang-3718320.html"
                    }
                };
                var result = await _emailSmsService.SendCommand(command);

                if (!result.IsSucess)
                {
                    model.AddMessage(result.Message);
                }
                else
                {
                    await _commonService.SetFlagRegisterSuccessAsync(result.ObjectId);
                }
                return(model);
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                throw e;
            }
        }
Example #3
0
 public void Create(EmailOrSmsBaseCommand command, string content)
 {
     Id             = Common.Common.GenerateGuid();
     CreatedDateUtc = command.CreatedDateUtc;
     UpdatedDateUtc = command.CreatedDateUtc;
     CreatedUid     = string.Empty;
     UpdatedUid     = string.Empty;
     Type           = command.Type;
     AddMessageType(command.MessageType);
     PhoneNumber = command.PhoneNumber;
     Email       = command.Email;
     SetTitle();
     SetVerify(command.VerifyAddCommand);
     Content = content;
     //SetContent(command);
 }
Example #4
0
        public async Task <CommandResult> SendCommand(EmailOrSmsBaseCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }