Пример #1
0
        public void SendActivationEmail(MailAddress email, ProviderMember aMember)
        {
            ProviderIssuedKey nonceIssuedKey = new ProviderIssuedKey();
            nonceIssuedKey.LoadOrCreate(aMember.Id.Value, email.Address, true, null, true);

            string activateUrl = HttpHost + "member/validate_email/" + nonceIssuedKey.IssuedKey;
            string deleteUrl = HttpHost + "member/delete/" + nonceIssuedKey.IssuedKey;
            string emailBody = "DO NOT SHARE THIS E-MAIL OR REPLY TO THIS E-MAIL<br />"
                            + "<br />"
                            + "<br />"
                            + "Click the link below to validate your e-mail with InsideWord:<br />"
                            + "<a href='" + activateUrl + "'>VALIDATE E-MAIL</a><br />"
                            + "<br />"
                            + "Don't know what this e-mail is about? Chances are someone used your e-mail by accident. Select the link below to delete the account:<br />"
                            + "<a href='" + deleteUrl + "'>DELETE ACCOUNT</a><br />"
                            + "<br />"
                            + "<br />"
                            + "<br />";
                            //+ DidYouKnow();

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - e-mail validation",
                                                        emailBody);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
        }
Пример #2
0
        /// <summary>
        /// Function to send an Edit/Delete e-mail to a member.
        /// </summary>
        /// <param name="anArticle">Article that member would like to edit/delete</param>
        /// <param name="aMember">Member that will receive the e-mail</param>
        /// <returns>true if the e-mail was sent successfully and false otherwise.</returns>
        public bool SendEditArticleEmail(MailAddress email, ProviderArticle anArticle, ProviderMember aMember)
        {
            ProviderIssuedKey nonceIssuedKey = new ProviderIssuedKey();
            nonceIssuedKey.LoadOrCreate(aMember.Id.Value, email.Address, true, null, true);

            // create a month issued key for editing the article
            ProviderIssuedKey monthExpiry = new ProviderIssuedKey();
            monthExpiry.LoadOrCreate(aMember.Id.Value, email.Address, false, 1, true);

            string editUrl = HttpHost + "article/edit/" + anArticle.Id.Value + "/" + monthExpiry.IssuedKey;
            string activateUrl = HttpHost + "member/change_password/" + nonceIssuedKey.IssuedKey;
            string deleteUrl = HttpHost + "member/delete/" + nonceIssuedKey.IssuedKey;
            string submitState = "";
            if (anArticle.IsPublished)
            {
                submitState = "Your article was submited to our system.";
            }
            else
            {
                submitState = "Your article was submited to our system as a draft.";
            }
            string category;
            if(anArticle.CategoryIds.Count > 0)
            {
                category = (new ProviderCategory(anArticle.CategoryIds[0])).Title;
            }
            else
            {
                category = "none";
            }

            string emailBody = "DO NOT SHARE THIS E-MAIL OR REPLY TO THIS E-MAIL<br />"
                            + "<br />"
                            + "<br />"
                            + submitState + "<br />"
                            + "Id: "+anArticle.Id.Value.ToString()+"<br />"
                            + "Title: "+anArticle.Title +"<br />"
                            + "Category: " + category + "<br />"
                            + "<br />"
                            + "Click the link below to edit/delete your article at InsideWord:<br />"
                            + "<a href='" + editUrl + "'>EDIT ARTICLE</a><br />"
                            + "<br />";

            if (!aMember.IsActive)
            {
                emailBody += "Click the link below to finish activating your account:<br />"
                            + "<a href='" + activateUrl + "'>FINISH ACTIVATING ACCOUNT</a><br />"
                            + "<br />"
                            + "Don't know what this e-mail is about? Chances are someone used your e-mail by accident. Select the link below to delete the account:<br />"
                            + "<a href='" + deleteUrl + "'>DELETE ACCOUNT</a><br />"
                            + "<br />";
            }

            emailBody += "<br />"
                        + "<br />"
                        + "<br />";
                        //+ DidYouKnow();

            MailMessage aMailMessage = new MailMessage("*****@*****.**",
                                                        email.Address,
                                                        "InsideWord - edit article " + anArticle.Title,
                                                        emailBody);
            aMailMessage.IsBodyHtml = true;
            DefaultSmtp.Send(aMailMessage);
            return true;
        }
Пример #3
0
        public virtual JsonResult DomainIdentificationRequest(string domainAddress)
        {
            string from = "APILOGINFO - " + HttpContext.Request.UserHostAddress;
            InsideWordWebLog.Instance.Buffer(from, "DomainIdentificationRequest(" + domainAddress + ")");
            ApiMsgVM returnMessage = new ApiMsgVM(1);

            Uri domainUri = null;

            if (!IWStringUtility.TryUrlDecode(domainAddress, out domainAddress) ||
                !Uri.TryCreate(domainAddress, UriKind.Absolute, out domainUri))
            {
                returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.failure;
                returnMessage.StatusMessage = domainAddress + " is an invalid uri";
            }
            else
            {
                ProviderDomain aDomain = new ProviderDomain();
                ProviderIssuedKey issuedKey = new ProviderIssuedKey();
                ProviderMember aMember = new ProviderMember();

                if (aDomain.Load(domainUri.AbsoluteUri))
                {
                    aMember.Load(aDomain.MemberId);
                }
                else
                {
                    // Domain doesn't exist already so create it and a member
                    aMember.CreateDate = DateTime.UtcNow;
                    aMember.EditDate = DateTime.UtcNow;
                    aMember.Save();

                    aDomain.CreateDate = DateTime.UtcNow;
                    aDomain.EditDate = DateTime.UtcNow;
                    aDomain.Domain = domainUri;
                    aDomain.IsValidated = false;
                    aDomain.MemberId = aMember.Id.Value;
                    aDomain.Save();
                }

                issuedKey.LoadOrCreate(aMember.Id.Value, domainUri.AbsoluteUri, true, 1, false);

                returnMessage.StatusCode = (int)ApiMsgVM.StatusEnum.success;
                returnMessage.StatusMessage = "Success";
                returnMessage.Content = issuedKey.IssuedKey;
            }
            InsideWordWebLog.Instance.Buffer(from, "Done DomainIdentificationRequest - " + returnMessage);
            return Json(returnMessage);
        }