Пример #1
0
        public ActionResult ResetPassword(string id)
        {
            if (null == id)
            {
                return(HttpNotFound());
            }



            try
            {
                Contact contact = (Contact)
                                  context.Retrieve("contact", new Guid(id), new Microsoft.Xrm.Sdk.Query.ColumnSet(true));

                contact.expl_Haslo        = (string)Session[id];
                contact.expl_salt         = (string)Session[id + "_salt"];
                contact.expl_passwordhash = (string)Session[id + "_hash"];

                context.Update(contact);

                context.SaveChanges();

                Session[id]           = null;
                Session[id + "_salt"] = null;
                Session[id + "_hash"] = null;
                Session.RemoveAll();
            }
            catch (Exception e)
            {
                Session[id]           = null;
                Session[id + "_salt"] = null;
                Session[id + "_hash"] = null;
                Session.RemoveAll();
                TempData["loginError"] = "Wystąpił błąd. Skontaktuj się z Administracją.";
                return(RedirectToAction("Index", "Login"));
            }

            Session[id]           = null;
            Session[id + "_salt"] = null;
            Session[id + "_hash"] = null;


            Session.RemoveAll();
            TempData["info"] = "Hasło zostało zmienione.";
            return(RedirectToAction("Index", "Login"));
        }