Example #1
0
        protected string FormatValue(UserAccountEvent evt, string value)
        {
            if (value == null) return null;

            var tokenizer = GetTokenizer(evt);
            return tokenizer.Tokenize(evt, this.ApplicationInformation, value);
        }
 public virtual void Process(UserAccountEvent evt, string phone = null)
 {
     var msg = CreateMessage(evt, phone);
     if (msg != null)
     {
         SendSms(msg);
     }
 }
 protected virtual Message CreateMessage(UserAccountEvent evt, string phone)
 {
     var msg = this.messageFormatter.Format(evt);
     if (msg != null)
     {
         msg.To = phone ?? evt.Account.MobilePhoneNumber;
     }
     return msg;
 }
Example #4
0
        private string GetMessageBody(UserAccountEvent accountEvent)
        {
            var txt = LoadTemplate();

            txt = txt.Replace("{applicationName}", ApplicationInformation.ApplicationName);
            txt = txt.Replace("{code}", accountEvent.Account.MobileCode);

            return txt;
        }
Example #5
0
        public Message Format(UserAccountEvent accountEvent)
        {
            if (accountEvent == null) throw new ArgumentNullException("accountEvent");

            var message = GetMessageBody(accountEvent);
            return new Message
            {
                Subject = message,
                Body = message
            };
        }
Example #6
0
 protected virtual Tokenizer GetTokenizer(UserAccountEvent evt)
 {
     Type type = evt.GetType();
     if (type == typeof(EmailChangeRequestedEvent)) return new EmailChangeRequestedTokenizer();
     if (type == typeof(EmailChangedEvent)) return new EmailChangedTokenizer();
     if (type == typeof(CertificateAddedEvent)) return new CertificateAddedTokenizer();
     if (type == typeof(CertificateRemovedEvent)) return new CertificateRemovedTokenizer();
     if (type == typeof(LinkedAccountAddedEvent)) return new LinkedAccountAddedTokenizer();
     if (type == typeof(LinkedAccountRemovedEvent)) return new LinkedAccountRemovedTokenizer();
     return new Tokenizer();
 }
Example #7
0
 protected virtual string GetSubject(UserAccountEvent evt)
 {
     return FormatValue(evt, LoadSubjectTemplate(evt));
 }
Example #8
0
 protected virtual string GetBody(UserAccountEvent evt)
 {
     return FormatValue(evt, LoadBodyTemplate(evt));
 }
Example #9
0
 public Message Format(UserAccountEvent accountEvent)
 {
     if (accountEvent == null) throw new ArgumentNullException("accountEvent");
     return CreateMessage(GetSubject(accountEvent), GetBody(accountEvent));
 }
Example #10
0
 public override string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
 {
     var evt = (LinkedAccountRemovedEvent)accountEvent;
     msg = base.Tokenize(accountEvent, appInfo, msg);
     msg = msg.Replace("{provider}", evt.LinkedAccount.ProviderName);
     return msg;
 }
Example #11
0
            public virtual string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
            {
                var user = accountEvent.Account;

                msg = msg.Replace("{username}", user.Username);
                msg = msg.Replace("{email}", user.Email);
                msg = msg.Replace("{mobile}", user.MobilePhoneNumber);

                msg = msg.Replace("{applicationName}", appInfo.ApplicationName);
                msg = msg.Replace("{emailSignature}", appInfo.EmailSignature);
                msg = msg.Replace("{loginUrl}", appInfo.LoginUrl);

                msg = msg.Replace("{confirmAccountCreateUrl}", appInfo.VerifyAccountUrl + user.VerificationKey);
                msg = msg.Replace("{cancelNewAccountUrl}", appInfo.CancelNewAccountUrl + user.VerificationKey);

                msg = msg.Replace("{confirmPasswordResetUrl}", appInfo.ConfirmPasswordResetUrl + user.VerificationKey);
                msg = msg.Replace("{confirmChangeEmailUrl}", appInfo.ConfirmChangeEmailUrl + user.VerificationKey);

                return msg;
            }
Example #12
0
 public override string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
 {
     var evt = (EmailChangeRequestedEvent)accountEvent;
     msg = base.Tokenize(accountEvent, appInfo, msg);
     msg = msg.Replace("{newEmail}", evt.NewEmail);
     msg = msg.Replace("{oldEmail}", accountEvent.Account.Email);
     return msg;
 }
Example #13
0
 public override string Tokenize(UserAccountEvent accountEvent, ApplicationInformation appInfo, string msg)
 {
     var evt = (CertificateRemovedEvent)accountEvent;
     msg = base.Tokenize(accountEvent, appInfo, msg);
     msg = msg.Replace("{thumbprint}", evt.Certificate.Thumbprint);
     msg = msg.Replace("{subject}", evt.Certificate.Subject);
     return msg;
 }
Example #14
0
 protected virtual string LoadSubjectTemplate(UserAccountEvent evt)
 {
     return LoadTemplate(evt.GetType().Name + "_Subject");
 }
Example #15
0
 protected virtual string LoadBodyTemplate(UserAccountEvent evt)
 {
     return LoadTemplate(evt.GetType().Name + "_Body");
 }
 public virtual void Process(UserAccountEvent evt, string email = null)
 {
     var msg = this.messageFormatter.Format(evt);
     if (msg != null)
     {
         msg.To = email ?? evt.Account.Email;
         this.messageDelivery.Send(msg);
     }
 }