예제 #1
0
        public static async Task SendActivationMail(RegisteredUser regUser)
        {
            var content = MailerContext.SelectEmailContent("ss");

            if (content == null)
            {
                content = new EmailTemplate()
                {
                    content = @"Hi [NAME], Your account has been Activated and your username is [USERNAME]. ",
                    subject = "Account Activation Confirmation"
                }
            }
            ;

            else if (string.IsNullOrEmpty(content.content))
            {
                content.content = @"Hi [NAME], Your account has been Activated and your username is [USERNAME].";
                content.subject = content.subject ?? "Account Activation Confirmation";
            }
            //var resetToken = "<a href='" + resetTokenAction + (DateTime.UtcNow.ToFileTimeUtc() + ":" + regUser.username).GenerateResetToken() + "'>Activation Link</a>";

            await Mailer.SendMailAsync(new MailContent()
            {
                ccAddress = "",
                Content   = HttpUtility.UrlDecode(HttpUtility.HtmlDecode(content.content))
                            .Replace("[NAME]", regUser.First_name + regUser.Middle_name + regUser.Last_name)
                            .Replace("[USERNAME]", regUser.Username)
                            .Replace("[LINK]", ""),
                Email      = regUser.Email_address,
                Subject    = content.subject,
                TypeOfMail = 1
            }, regUser.Username, regUser.RegistereduserId);
        }
예제 #2
0
        public static async Task SendBlockedMail(RegisteredUser regUser, string originIp)
        {
            // OTP p = new OTP();
            // long Datetimenow = DateTime.UtcNow.ToFileTimeUtc();
            //OTP O = new OTP(x, Guid.NewGuid().ToByteArray());
            //long Datetimenow = DateTime.UtcNow.ToFileTimeUtc();
            //string token = O.GetCurrentOTP();
            //UIContext.RegisterToken(token, "originip", regUser.user_identifier);
            long   Datetimenow = DateTime.UtcNow.Ticks;
            string t           = regUser.RegistereduserId.ToString() + Guid.NewGuid().ToString();
            string tokens      = ClsFunction.GenerateResetToken(t + ":" + Datetimenow);
            string new_token   = Regex.Replace(tokens, "[^0-9a-zA-Z]+", "");
            string link        = ConfigurationManager.AppSettings["URL_BASE_ResetPassword"];
            string regLink     = string.Format(link, HttpUtility.UrlEncode(new_token));
            var    resetToken  = "<a href='" + regLink + "'>Activation Link</a>";

            RegistrationContext.ResetPasswordToken(regUser.RegistereduserId, new_token, originIp);

            var content = MailerContext.SelectEmailContent("ss");

            if (content == null)
            {
                content = new EmailTemplate()
                {
                    content = @"Hi [NAME], Your Account has been blocked.
                                <br/> Please use the below link to reset your account.<br/>[LINK]<br/>Please note this link will expire in 24 hours",
                    subject = "Your Account has been blocked"
                }
            }
            ;

            else if (string.IsNullOrEmpty(content.content))
            {
                content.content = @"Hi [USERNAME],Your Account has been blocked.
                                <br/>Please use the below OTP to reset your account.<br/>[LINK]<br/>Please note this OTP will expire in 24 hours";
                content.subject = content.subject == "" || content.subject == null ? "Invalid Logn Attempt" : content.subject;
            }
            //var resetToken = "<a href='" + resetTokenAction + (DateTime.UtcNow.ToFileTimeUtc() + ":" + regUser.username).GenerateResetToken() + "'>Activation Link</a>";

            await Mailer.SendMailAsync(new MailContent()
            {
                ccAddress = "",
                Content   = HttpUtility.UrlDecode(HttpUtility.HtmlDecode(content.content))
                            .Replace("[NAME]", regUser.First_name + regUser.Middle_name + regUser.Last_name)
                            .Replace("[USERNAME]", regUser.Username)
                            .Replace("[LINK]", ""),
                Email      = regUser.Email_address,
                Subject    = content.subject,
                TypeOfMail = 1
            }, regUser.Username, regUser.RegistereduserId);
        }
예제 #3
0
        public static async Task SendMail(RegisteredUser regUser)
        {
            //OTP otp = new OTP();
            //OTP otp;
            // OTP O = new OTP(x,Guid.NewGuid().ToByteArray());
            long Datetimenow = DateTime.UtcNow.Ticks;
            //string token = O.GetCurrentOTP();//OTPGeneration.GenerateOTP();
            // string t = otp.GetNextOTP();
            string t          = regUser.RegistereduserId.ToString() + Guid.NewGuid().ToString();
            string token      = ClsFunction.GenerateResetToken(t + ":" + Datetimenow);
            string new_token  = Regex.Replace(token, "[^0-9a-zA-Z]+", "");
            string link       = ConfigurationManager.AppSettings["URL_BASE_Register"];
            string regLink    = string.Format(link, HttpUtility.UrlEncode(new_token));
            var    resetToken = "<a href='" + regLink + "'>Activation Link</a>";

            RegistrationContext.RegisterToken(new_token, regUser.Registration_ip, regUser.RegistereduserId);

            var content = MailerContext.SelectEmailContent("ss");

            if (content == null)
            {
                content = new EmailTemplate()
                {
                    content = @"Hi [NAME], Your account has been created and your username is [USERNAME]
                        <br/>Please use the below link to activate your account.<br/>Your LINK is [LINK]<br/>Please note this link will expire in 24 hours",
                    subject = "Your account has been created"
                }
            }
            ;

            else if (string.IsNullOrEmpty(content.content))
            {
                content.content = @"Hi [NAME], Your account has been created and your username is [USERNAME]
                        <br/>Please use the below link to activate your account.<br/>Your LINK is [LINK]<br/>Please note this link will expire in 24 hours";
                content.subject = content.subject ?? "Your account has been created";
            }
            //var resetToken = "<a href='" + resetTokenAction + (DateTime.UtcNow.ToFileTimeUtc() + ":" + regUser.username).GenerateResetToken() + "'>Activation Link</a>";

            await Mailer.SendMailAsync(new MailContent()
            {
                ccAddress = "",
                Content   = HttpUtility.UrlDecode(HttpUtility.HtmlDecode(content.content))
                            .Replace("[NAME]", regUser.First_name + regUser.Middle_name + regUser.Last_name)
                            .Replace("[USERNAME]", regUser.Username)
                            .Replace("[LINK]", resetToken),
                Email      = regUser.Email_address,
                Subject    = content.subject,
                TypeOfMail = 1
            }, regUser.Username, regUser.RegistereduserId);
        }