コード例 #1
0
        public CCToken SaveToken(CCToken tokensObj)
        {
            if (tokensObj.ID == 0)
            {
                context.CCTokens.Add(tokensObj);
                context.SaveChanges();
            }

            return tokensObj;
        }
コード例 #2
0
        public ActionResult ForgotPassword(ForgotPasswordModel forgotpassword)
        {
            var getPassword = "";

            var res = userRepository.Users.Where(umail => umail.Email == forgotpassword.EmailAddress).ToList();

            if (res.Count() > 0)
            {
                getPassword = res.FirstOrDefault(umail => umail.Email == forgotpassword.EmailAddress).Password;
            }

            if (getPassword != "")
            {
                var accoundID = res.FirstOrDefault(umail => umail.Email == forgotpassword.EmailAddress).AccountID;

                string url = HttpContext.Request.Url.AbsoluteUri;
                url = url.Replace("Forgot", "Reset");

                Guid guid = Guid.NewGuid();

                var isExistToken = CCTokenRepository.CCTokens.Where(t => t.AccountID == accoundID);

                if (isExistToken.Count() > 0)
                {
                    var tokenID = isExistToken.FirstOrDefault().ID;
                    CCTokenRepository.DeleteToken(tokenID);
                }

                CCToken objToken = new CCToken();
                objToken.AccountID = accoundID;
                objToken.Token = guid.ToString();
                CCTokenRepository.SaveToken(objToken);

                string body = "Please click on the following link to reset your password " + Environment.NewLine + url +
                                       "?te76emjj55hz=" + guid.ToString();
                var userObj = res.FirstOrDefault(umail => umail.Email == forgotpassword.EmailAddress);

                //new user
                var notifObj = new Notification()
                {
                    Subject = "Corporate Contacts – Reset password",
                    RecipientAddress = forgotpassword.EmailAddress,
                    Message = "<div><center> <table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%'> <tbody><tr> <td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='600'> <tbody><tr> </tr><tr> <td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%'> <tbody><tr> <td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='600'> <tbody><tr> <td align='center' valign='top' width='600' style='padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;border-top:1px solid #cccccc;border-right:1px solid #cccccc;border-left:1px solid #cccccc;background-color:#ffffff'><img src='http://corporate-contacts.com/wp-content/uploads/2014/03/CorporateContactslogo3a2.png' style='max-width: 450px;margin-top: 20px;' alt='Dyn'></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr> <td align='center' valign='top' style='border-left:1px solid #cccccc;border-right:1px solid #cccccc;background-color:#ffffff'><table border='0' cellpadding='0' cellspacing='0' width='100%' style='background-color:#ffffff'> <tbody><tr> <td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%'> <tbody><tr> <td valign='top' style='padding-top:20px;padding-right:30px;padding-left:30px'><table align='left' border='0' cellpadding='0' cellspacing='0'> <tbody><tr> <td valign='top' style='color:#444444;font-family:Helvetica;font-size:16px;line-height:125%;text-align:left;padding-bottom:20px'><p>Dear " + userObj.FullName + "</p><p>Corporate Contacts received a request to reset your password for your account.</p><p>Click on the link below (or copy and paste it) to reset your password.</p><p><a href='" + Request.Url.GetLeftPart(UriPartial.Authority) + Url.RouteUrl(new { controller = "Login", action = "ResetPassword" }) + "?te76emjj55hz=" + guid.ToString() + "'>" + Request.Url.GetLeftPart(UriPartial.Authority) +Url.RouteUrl(new { controller = "Login", action = "ResetPassword" }) + "?te76emjj55hz=" + guid.ToString() + "</a></p><p>If you did not make this request please contact us at www.support.corporate-contacts.com so we can look in to this matter for you.  </p><p>Regards,<br><a style='text-decoration:underline;color:#0066cc' href='http://corporate-contacts.com/' target='_blank'>The Corporate Contacts team</a></p><p><a href='http://www.support.corporate-contacts.com'>www.support.corporate-contacts.com</a></p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr> <td align='center' valign='top' style='border-left:1px solid #cccccc;border-right:1px solid #cccccc'><table border='0' cellpadding='0' cellspacing='0' width='100%' style='background-color: #209FD1;'> <tbody><tr> <td align='center' valign='bottom'><table border='0' cellpadding='0' cellspacing='0' width='600'> <tbody><tr> <td valign='bottom' width='600' style='padding-top:0px;padding-right:20px;padding-left:20px;padding-bottom:10px'><table align='left' border='0' cellpadding='0' cellspacing='0' width='100%'> <tbody><tr> <td valign='bottom' style='color:#ffffff;padding-top:10px;font-family:Helvetica;font-size:12px;line-height:150%;text-align:left'>Corporate Contacts Ltd.<br>Beverley, UK, HU17 0LD<br>Manchester, NH 03101</td><td valign='bottom' style='color:#ffffff;padding-top:10px;font-family:Helvetica;font-size:12px;line-height:150%;text-align:left'>Phone: +44 1482 869700<br>E-Mail: [email protected]</td></tr></tbody></table> </td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></center></div>"
                };
                notifManager.SendNotification(notifObj);

                ViewBag.MessageFail = "";
                ViewBag.MessagePass = "******"; //FineTune:use green Color in Web page

            }
            else
            {
                ViewBag.MessagePass = "";
                ViewBag.MessageFail = "Invalid email address."; //ToDo:FineTune:Make this Client side
            }

            return View(forgotpassword);
        }