public ViewResult AccountConfirmation(Models.User user, string emailUrl) { var host = Request.Url.Host; var accountKey = CryptoService.EncryptAccountConfirmation(user.Email, user.Id); var urlHelper = new UrlHelper(ControllerContext.RequestContext); var accountConfirmationUrl = urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT_CONFIRMATION, null); string confirmationUrl = string.Format("http://{0}{1}{2}", host, accountConfirmationUrl, accountKey); ViewData.Model = user; ViewData["confirmationUrl"] = confirmationUrl; ViewBag.ConfirmationUrl = confirmationUrl; ViewData["encryptedUrl"] = emailUrl; ViewBag.EncryptedUrl = emailUrl; ViewBag.User = user; ViewBag.WebSiteSettings = ERPStore.ERPStoreApplication.WebSiteSettings; return View(); }
public ViewResult ChangePassword(string personFullName, string callbackUrl, string encryptedUrl) { var urlHelper = new UrlHelper(ControllerContext.RequestContext); ViewData["FullName"] = personFullName; ViewBag.FullName = personFullName; ViewData["EncryptedUrl"] = callbackUrl; ViewBag.CallbackUrl = callbackUrl; ViewData["EncryptedUrl2"] = encryptedUrl; ViewBag.EncryptedUrl = encryptedUrl; ViewData["accountUrl"] = urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT, null); ViewBag.WebSiteSettings = ERPStore.ERPStoreApplication.WebSiteSettings; return View(); }
public ViewResult NewCustomerOrderConfirmation(Models.ISaleDocument order, string encrypteUrl, string password) { var urlHelper = new UrlHelper(ControllerContext.RequestContext); string accountUrl = string.Format("http://{0}{1}", Request.Url.Host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT)); ViewData["accountUrl"] = accountUrl; ViewData["encryptedUrl"] = encrypteUrl; ViewData["password"] = password; ViewData.Model = order; return View(); }
public ViewResult OrderConfirmation(Models.ISaleDocument order, string emailUrl) { var host = Request.Url.Host; var urlHelper = new UrlHelper(ControllerContext.RequestContext); string accountUrl = string.Format("http://{0}{1}", host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT)); ViewData["accountUrl"] = accountUrl; ViewData["encryptedUrl"] = emailUrl; ViewData.Model = order; return View(); }
public ActionResult DirectNewCustomerOrderConfirmation(string key) { if (key.IsNullOrTrimmedEmpty()) { return new EmptyResult(); } var mailKey = new { Code = string.Empty, Type = string.Empty, Password = string.Empty, Salt = DateTime.Now, }; var result = CryptoService.Decrypt(key, mailKey); var code = Convert.ToString(result[0]); var type = Convert.ToString(result[1]); var password = Convert.ToString(result[2]); var salt = Convert.ToDateTime(result[3]); Models.ISaleDocument order = null; switch (type) { case "order": order = SalesService.GetOrderByCode(code); break; case "quote": order = SalesService.GetQuoteByCode(code); break; default: break; } var host = this.Request.Url.Host; var encryptedTicket = CryptoService.EncryptOrderConfirmation(order.Code, DateTime.Now.AddDays(10), false); var urlHelper = new UrlHelper(this.ControllerContext.RequestContext); string accountUrl = string.Format("http://{0}{1}", host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT)); string encryptedUrl = string.Format("http://{0}{1}{2}", host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ORDER_DETAIL), encryptedTicket); ViewData["accountUrl"] = accountUrl; ViewData["encryptedUrl"] = encryptedUrl; ViewData["password"] = password; ViewData.Model = order; return View("NewCustomerOrderConfirmation"); }
public ActionResult DirectOrderConfirmation(string key) { var mailKey = new { Code = string.Empty, Type = string.Empty, Salt = DateTime.Now, }; var result = CryptoService.Decrypt(key, mailKey); var code = Convert.ToString(result[0]); var type = Convert.ToString(result[1]); var salt = Convert.ToDateTime(result[2]); Models.ISaleDocument order = null; switch (type) { case "order": order = SalesService.GetOrderByCode(code); break; case "quote": order = SalesService.GetQuoteByCode(code); break; default: break; } var urlHelper = new UrlHelper(ControllerContext.RequestContext); string accountUrl = string.Format("http://{0}{1}", Request.Url.Host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT)); var encryptedTicket = CryptoService.EncryptOrderConfirmation(order.Code, DateTime.Now.AddDays(10), false); string encryptedUrl = string.Format("http://{0}{1}{2}", Request.Url.Host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ORDER_DETAIL), encryptedTicket); ViewData.Model = order; ViewData["accountUrl"] = accountUrl; ViewData["encryptedUrl"] = encryptedUrl; ViewBag.EncryptedUrl = encryptedUrl; ViewBag.User = order.User; ViewBag.FullName = order.User.FullName; ViewBag.WebSiteSettings = ERPStoreApplication.WebSiteSettings; ViewBag.EncryptedUrl = encryptedUrl; return View("OrderConfirmation"); }
public ActionResult DirectChangePassword(string key) { var mailKey = new { UserId = 0, ExpirationDate = DateTime.MinValue, }; var result = CryptoService.Decrypt(key, mailKey); var userId = Convert.ToInt32(result[0]); var expirationDate = Convert.ToDateTime(result[1]); if (expirationDate < DateTime.Today) { return Content("Clé invalide", "text/plain"); } var user = AccountService.GetUserById(userId); var host = Request.Url.Host; var callbackKey = CryptoService.EncryptChangePassword(user.Id, user.Email); var urlHelper = new UrlHelper(ControllerContext.RequestContext); var callbackUrl = string.Format("http://{0}{1}/{2}", host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT_CHANGE_PASSWORD), callbackKey); var view = ChangePassword(user.FullName, callbackUrl, "#"); view.ViewName = "ChangePassword"; return view; }
public ActionResult RecoverPassword(string loginOrEmail) { var user = AccountService.GetUserByEmailOrLogin(loginOrEmail); if (user == null) { ModelState.AddModelError("_FORM", "Identifiant inconnu"); return View(); } var host = Request.Url.Host; var key = CryptoService.EncryptChangePassword(user.Id, user.Email); var urlHelper = new UrlHelper(ControllerContext.RequestContext); var url = string.Format("http://{0}{1}/{2}", host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.ACCOUNT_CHANGE_PASSWORD), key); ViewData["key"] = key; try { EmailerService.SendChangePassword(this, user, url); ViewData["PasswordSent"] = true; } catch(Exception ex) { LogError(Logger, ex); ModelState.AddModelError("_FORM", "Un problème technique empeche l'execution de cette opération"); } return View(); }
public virtual void SendOrderConfirmation(System.Web.Mvc.Controller controller, ERPStore.Models.ISaleDocument order) { if (order.User.Email.IsNullOrTrimmedEmpty()) { return; } var urlHelper = new UrlHelper(controller.ControllerContext.RequestContext); var mailKey = new { Code = order.Code, Type = (order is Models.Order) ? "order" : "quote", Salt = DateTime.Now, }; var encrytpedMailKey = CryptoService.Encrypt(mailKey); string encrytpedEmailUrl = string.Format("http://{0}{1}", controller.HttpContext.Request.Url.Host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.EMAILER, new { action = "DirectOrderConfirmation", key = encrytpedMailKey, })); var body = controller.GetActionOutput<ERPStore.Controllers.EmailerController>(i => i.OrderConfirmation(order, encrytpedEmailUrl)); if (body == null) { return; } var message = new MailMessage(); message.Body = body; message.To.Add(new MailAddress(order.User.Email, order.User.FullName)); message.Subject = string.Format("[{0}] Votre commande N°{1}", ERPStoreApplication.WebSiteSettings.SiteName, order.Code); message.IsBodyHtml = true; Send(message); }
public virtual void SendChangePassword(System.Web.Mvc.Controller controller, ERPStore.Models.User user, string callbackUrl) { var urlHelper = new UrlHelper(controller.ControllerContext.RequestContext); var mailKey = new { UserId = user.Id, ExpirationDate = DateTime.Now, }; var encrytpedMailKey = CryptoService.Encrypt(mailKey); string encrytpedEmailUrl = string.Format("http://{0}{1}", controller.HttpContext.Request.Url.Host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.EMAILER, new { action = "DirectSendChangePassword", key = encrytpedMailKey, })); var body = controller.GetActionOutput<Controllers.EmailerController>(i => i.ChangePassword(user.FullName, callbackUrl, encrytpedEmailUrl)); var email = new MailMessage(); email.Body = body; email.To.Add(new MailAddress(user.Email, user.FullName)); email.Subject = string.Format("[{0}] Demande de changement de mot de passe", ERPStoreApplication.WebSiteSettings.SiteName); email.IsBodyHtml = true; Send(email); }
public virtual void SendAccountConfirmation(System.Web.Mvc.Controller controller, ERPStore.Models.User user) { var urlHelper = new UrlHelper(controller.ControllerContext.RequestContext); var mailKey = new { UserId = user.Id, Salt = Guid.NewGuid().ToString(), }; var encrytpedMailKey = CryptoService.Encrypt(mailKey); string encrytpedEmailUrl = string.Format("http://{0}{1}", controller.HttpContext.Request.Url.Host, urlHelper.RouteERPStoreUrl(ERPStoreRoutes.EMAILER, new { action = "DirectAccountConfirmation", key = encrytpedMailKey, })); var body = controller.GetActionOutput<Controllers.EmailerController>(i => i.AccountConfirmation(user, encrytpedEmailUrl)); if (body == null) { return; } var message = new MailMessage(); message.Body = body; message.To.Add(new MailAddress(user.Email, user.FullName)); message.Subject = string.Format("[{0}] Confirmation de votre compte", ERPStoreApplication.WebSiteSettings.SiteName); message.IsBodyHtml = true; Send(message); }