Example #1
0
        public async Task SendMailVerificationCode(string mailAddress)
        {
            var code = VerificationCodeGenerater.GenerateCode();
            Expression <Func <Task> > expression = () => _emailSender.SendMessage(mailAddress, L("VerificationSubject"), string.Format(L("VerificationBody"), code));

            Hangfire.BackgroundJob.Schedule(expression, TimeSpan.Zero);
            await _messageHistoryRepository.InsertAsync(new MessageHistory { Code = code, Type = MessageType.Mail, Message = string.Format(L("VerificationBody"), code), To = mailAddress });
        }
Example #2
0
        public async Task SendSmsVerificationCode(string phoneNumber)
        {
            var code      = VerificationCodeGenerater.GenerateCode();
            var smsParams = new Dictionary <string, string>()
            {
                { "code", code }
            };
            Expression <Func <Task> > expression = () => _smsMessage.SendMessage(phoneNumber, "", smsParams);

            Hangfire.BackgroundJob.Schedule(expression, TimeSpan.Zero);
            await _messageHistoryRepository.InsertAsync(new MessageHistory { Code = code, Type = MessageType.Sms, Message = code, To = phoneNumber });
        }
Example #3
0
 public Task <bool> Verify(string code)
 {
     return(new ValueTask <bool>(VerificationCodeGenerater.Verify(code)).AsTask());
 }