Exemplo n.º 1
0
        public ActionResult UserResetPassword(FormCollection frm)
        {
            try
            {
                Int32  userID = Convert.ToInt32(frm["userID"]);
                String key    = frm["key"];
                //String LoginID = frm["LoginID"];
                String Password = frm["password"];
                //String BusinessName = frm["BusinessName"];



                var userInfo = db.users.AsEnumerable().Where(x => x.user_id == userID && x.activation_reset_key == key && x.is_active == true).FirstOrDefault();
                if (userInfo != null)
                {
                    if (userInfo.reset_password_link_expire_date_time > STUtil.GetCurrentDateTime())
                    {
                        userUtil.ResetUser(userID, key, Password);


                        String LoginResult = RoleUtil.CheckUserFrofile("", "", userInfo.user_id);
                        if (LoginResult == "PASS")
                        {
                            var list        = RoleUtil.GetMenusOfRoleId(Convert.ToInt32(STUtil.GetSessionValue(UserInfo.RoleID.ToString())), Convert.ToInt32(STUtil.GetSessionValue(UserInfo.RoleID.ToString()))).ToList();
                            var menuObjects = (Session[UserInfo.MenuList.ToString()] as List <TreeNode>) ?? new List <TreeNode>();
                            menuObjects.AddRange(list);
                            Session[UserInfo.MenuList.ToString()] = menuObjects;



                            return(RedirectToAction("Index/", "DashBoard"));
                        }


                        else
                        {
                            return(RedirectToAction("Login", "Account", new { result = "Invalid Request", MessageType = "Error" }));
                        }
                    }
                    else
                    {
                        ViewBag.result = "Your password reset link has been expired!!!";
                        return(RedirectToAction("Login", "Account", new { result = "Your password reset link has been expired!!!", MessageType = "Error" }));
                    }
                }
                else
                {
                    ViewBag.result = "Invalid Request";
                    return(RedirectToAction("Login", "Account", new { result = "Invalid Request", MessageType = "Error" }));
                }
            }
            catch (Exception ex)
            {
                ViewBag.result = ex.Message;
                return(RedirectToAction("Login", "Account", new { result = ex.Message, MessageType = "Error" }));
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult UserResetPassword(Int32 userID, String key)
        {
            try
            {
                var userInfo = db.users.AsEnumerable().Where(x => x.user_id == userID && x.activation_reset_key == key && x.is_active == true).FirstOrDefault();
                if (userInfo != null)
                {
                    if (userInfo.reset_password_link_expire_date_time > STUtil.GetCurrentDateTime())
                    {
                        ViewBag.UserName              = userInfo.user_name;
                        ViewBag.EmailID               = userInfo.email_id;
                        ViewBag.userID                = userInfo.user_id;
                        ViewBag.loginID               = userInfo.login_id;
                        ViewBag.BusinessName          = userInfo.company.business_name;
                        ViewBag.key                   = userInfo.activation_reset_key;
                        ViewBag.link_expire_date_time = userInfo.reset_password_link_expire_date_time;
                        ViewBag.result                = "";
                    }
                    else
                    {
                        ViewBag.result = "Your password reset link has been expired!!!";
                        return(RedirectToAction("Login", "Account", new { result = "Your password reset link has been expired!!!", MessageType = "Error" }));
                    }
                }
                else
                {
                    ViewBag.result = "Invalid Request";
                    return(RedirectToAction("Login", "Account", new { result = "Invalid Request", MessageType = "Error" }));
                }
            }
            catch (Exception ex)
            {
                ViewBag.result = ex.Message;
                return(RedirectToAction("Login", "Account", new { result = ex.Message, MessageType = "Error" }));
            }

            return(View());
        }