Esempio n. 1
0
        public JsonResult Vote(int id, string c = "")
        {
            string userip = null;
            userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (userip == null)
                userip = Request.ServerVariables["REMOTE_ADDR"];

            string signalr_hub = "http://*****:*****@gmail.com";

                string hub_state = "";
                if (hubConnection != null)
                {
                    hub_state = hubConnection.State.ToString();
                }
                else
                {
                    hub_state = "null";
                }
                msg.Message = "state: " + hub_state + "<br><br>" + ex.Message.ToString();
                if (ex.InnerException != null)
                {
                    msg.Message = msg.Message + "<br><br>" + ex.InnerException.Message.ToString();
                }

                _mailService.SendContact(msg.Message, msg.Email);

            }

            return Json(letter, JsonRequestBehavior.AllowGet);
        }
Esempio n. 2
0
        public ActionResult Password(string email = "", int what = 1, string id = "", string pass = "")
        {
            try
            {

                Core.Model.Contact msg = new Core.Model.Contact();

                switch (what)
                {
                    // this is the default route,
                    // the user has just entered
                    // their email and we need to
                    // make sure that there is
                    // a user that exists for that
                    // email!

                    case 1:

                        var lost_user = _userService.getUserByEmail(email);

                        if (lost_user == null)
                        {

                            ViewBag.Stage = 5;
                            ViewBag.ErrorTitle = "unable to find that account.";
                            ViewBag.ErrorMessage = "we looked really hard, but we couldn't find that account.";

                        }
                        else
                        {

                            var password_change_request = _userService.AddLostPassword(lost_user.UserId.ToString());

                            msg.Email = email;

                            string message_body;
                            message_body = "Hello, \n\n" +
                                            "You requested a password reset. Please click this " +
                                            "link to change your password:\n" +
                                            "http://letterstocrushes.com/password/" + password_change_request.cguid + "\n\n" +
                                            "sincerely,\nletters to crushes";

                            msg.Message = message_body;

                            _mailService.SendPasswordLink(msg.Message, msg.Email);
                            ViewBag.Email = email;
                            ViewBag.Stage = 2;

                        }

                        break;
                    case 3:

                        // ok, we just received a new password.
                        // time to change it!

                        var lost_password = _userService.GetLostPassword(id);
                        Guid user_guid = Guid.Parse(lost_password.userguid);
                        lost_user = _userService.getUserByGuid(user_guid);

                        MembershipUser user = Membership.Provider.GetUser(lost_user.UserName, false);

                        // some users were getting locked out if they
                        // reset their passwords too much
                        if (user.IsLockedOut == true)
                        {
                            user.UnlockUser();
                        }

                        string newPassword = pass;
                        string tempPassword = user.ResetPassword();

                        user.ChangePassword(tempPassword, newPassword);

                        // now log the user in...

                        if (MembershipService.ValidateUser(lost_user.UserName, newPassword))
                        {
                            FormsService.SignIn(lost_user.UserName, true);
                            return RedirectToAction("Index", "Account", null);
                        }
                        else
                        {

                            // there was an error :(

                            ViewBag.Stage = 5;
                            ViewBag.ErrorTitle = "error! :(";
                            ViewBag.ErrorMessage = "there was an error signing in.";
                        }

                        break;
                }

            }
            catch (Exception ex)
            {

                Core.Model.Contact error_msg = new Core.Model.Contact();
                error_msg.Email = "change password";
                string message = "stage: " + what + "<br/>" + ex.Message.ToString();

                if (ex.InnerException != null)
                {
                    message = message + "<br /><br />" + ex.InnerException.ToString();
                }

                error_msg.Message = message;

                _mailService.SendContact(error_msg.Message, error_msg.Email);

            }

            return View();
        }
Esempio n. 3
0
        public ActionResult PublishQueue()
        {
            Core.Model.Letter published = _queueService.PublishQueue();
            Core.Model.Contact msg = new Core.Model.Contact();

            if (published == null)
            {

                msg.Email = "*****@*****.**";
                msg.Message = "Tried to publish from queue but it was empty.";
                _mailService.SendContact(msg.Message,msg.Email);
            }
            else
            {
                msg.Email = "*****@*****.**";
                msg.Message = "Published:\r\n " + published.letterMessage;
                _mailService.SendContact(msg.Message, msg.Email);
            }
            return RedirectToAction("Index");
        }
Esempio n. 4
0
        public void SendNotifications(int letter_id, string host)
        {
            List<Comment> comments = getComments(letter_id, true);
            List<string> sent_address = new List<string>();

            foreach (Comment comment in comments)
            {

                System.Diagnostics.Debug.Print("Comment from " + comment.commenterEmail + " - wants update: " + comment.sendEmail);

                if (comment.sendEmail == true && sent_address.Contains(comment.commenterEmail) == false)
                {

                    Contact notification = new Contact();
                    notification.Email = comment.commenterEmail;
                    notification.Message = "Hello, <br><br>"
                        + "A new comment has been posted to " + host + "letter/" + comment.letterId
                        + "<br><br>Thought you'd like to know,<br>the letters to crushes team<br><br>_____________<br>unsubscribe: " + host + "unsubscribe/" + comment.letterId + "/" + comment.commenterEmail;

                    // add the email to a list of previously sent addresses
                    // we do not want to send multiple email notifications
                    // if they have commented in the same thread.
                    sent_address.Add(comment.commenterEmail);

                    _mailService.SendCommentNotification(notification.Message, notification.Email);

                }

            }
        }