public ActionResult MyRight() { EnergyMonitor.Models.LinqEntity.User loginUser = Session["loginUser"] as EnergyMonitor.Models.LinqEntity.User; var functionList = _functionRepos.GetRoleFuns(loginUser.USR_RoleID); return(View(functionList)); }
/// <summary> /// 修改用户信息 /// </summary> /// <param name="userName">用户名</param> /// <param name="userEmail">邮箱,修改后需要激活</param> /// <param name="userDepartment">所属院系</param> /// <param name="departmentName">所属院系名称</param> /// <returns></returns> public ActionResult ModifiedInfo(string userName, string userEmail, int userDepartment, string departmentName) { bool isModified = false; EnergyMonitor.Models.LinqEntity.User loginUser = Session["loginUser"] as EnergyMonitor.Models.LinqEntity.User; if (!String.IsNullOrWhiteSpace(userName) && loginUser.USR_Name != userName) { loginUser.USR_Name = userName; Session["loginUserName"] = userName; isModified = true; } string activeStr = null; if (!String.IsNullOrWhiteSpace(userEmail) && loginUser.USR_Mail != userEmail) { loginUser.USR_Mail = userEmail; activeStr = Guid.NewGuid().ToString(); loginUser.USR_MailActiveCode = activeStr; isModified = true; } if (userDepartment > 0 && loginUser.USR_DepartID != userDepartment) { loginUser.USR_DepartID = userDepartment; isModified = true; } if (!String.IsNullOrWhiteSpace(departmentName) && loginUser.USR_DepartName != departmentName) { loginUser.USR_DepartName = departmentName; isModified = true; } if (isModified) { if (_userRepos.ModifyUserInfo(loginUser) == null) { return(RedirectToAction("Error", "Shared")); } if (activeStr != null)//需要激活邮箱 { string webSiteName = "http://" + Request.Url.Authority; // 线程发送 new Thread(delegate() { Util.SendActiveMail(webSiteName, userEmail, loginUser.USR_ID, userName, "/Homes/ActiveMail", activeStr); }).Start(); ViewBag.isMailSendError = false; ViewBag.mailAddr = userEmail; } else { ViewBag.isMailSendError = null; } } ViewBag.isModified = isModified; return(View("RedirectPage")); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { EnergyMonitor.Models.LinqEntity.User u = filterContext.HttpContext.Session["loginUser"] as EnergyMonitor.Models.LinqEntity.User; string actionName = filterContext.RouteData.Values["action"].ToString(); //验证用户是否登录 if (filterContext.HttpContext.Session["loginUser"] == null && (!"QueryBuyHistoryAjax".Equals(actionName)) && (!"getDepartmentList".Equals(actionName)) && (!"Reactive".Equals(actionName)) && (!"EnergyBriefVal".Equals(actionName)) && (!"GetRoomEnergyAjax".Equals(actionName)) && (!"GetDetailRoomEnergyAjax".Equals(actionName)) && (!"GetAllShoolAjax".Equals(actionName)) && (!"GetAreasBySchoolIDAjax".Equals(actionName)) && (!"GetBuildingByAreaAjax".Equals(actionName)) && (!"GetRoomsByBIDAjax".Equals(actionName)) && (!"Registered".Equals(actionName)) && (!"GetAreasBySchoolIDAjax".Equals(actionName)) && (!"GetPointsByBuildingAjax".Equals(actionName)) && (!"GetBuildingByAreaAjax".Equals(actionName)) && (!"Register".Equals(actionName)) && (!"EnergyBriefValForMobile".Equals(actionName)) && (!"GetAllDepartment".Equals(actionName)) && (!"RegisteredForMobile".Equals(actionName)) && (!"QueryBuyHistoryAjaxForMobile".Equals(actionName))) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Homes", action = "NoLogin", Area = "" })); return; } }
/// <summary> /// 激活邮箱 /// </summary> /// <param name="userID">用户ID</param> /// <param name="activeStr">激活码</param> /// <returns></returns> public ActionResult ActiveMail(string userID, string activeStr) { EnergyMonitor.Models.LinqEntity.User user = _userRepos.ActiveMail(userID, activeStr); if (user != null) { DateTime loginTime = DateTime.Now; string loginIP; if (HttpContext.Request.ServerVariables["HTTP_VIA"] != null) { loginIP = HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else { loginIP = HttpContext.Request.ServerVariables["REMOTE_ADDR"].ToString(); } // 修改登录时间和IP _userRepos.ModifyUserInfo(user.USR_ID, loginTime.ToString(), loginIP); if (user.USR_Status) { Session["loginUser"] = user; Session["loginUserName"] = user.USR_Name; Session["userRoomInfo"] = null; } else//用户被禁用 { return(View("Disabled")); } TempData["activeFlag"] = true; if (user.USR_RoleID == 1)//先写死为1认为是学生用户 { return(RedirectToAction("ActiveMail", "User", new { area = "User" })); } else//非学生用户 { //获取权限 var functionList = _functionRepos.GetRoleFuns(user.USR_RoleID); var functionLinkList = functionList.Where(x => x.FN_ID.Length > 6).Select(x => x.FN_LinkLocation).ToList(); var navFunctionList = functionList.Where(x => x.FN_ID.Length == 6).ToList(); var subFunctionList = functionList.Where(x => x.FN_ID.Length == 9).ToList(); var fullSubFunctionList = functionList.Where(x => x.FN_ID.Length > 6).ToList(); Session["userFunctionLinks"] = functionLinkList; Session["userNavFunctions"] = navFunctionList; Session["userSubFunctions"] = subFunctionList; Session["fullSubFunctionList"] = fullSubFunctionList; return(RedirectToAction("ActiveMail", "User", new { area = "Admin" })); } } return(View()); }
/// <summary> /// 重新发送激活邮件 /// </summary> /// <returns></returns> public ActionResult Reactive() { if (TempData["tempLoginUser"] == null) { return(View("Error")); } EnergyMonitor.Models.LinqEntity.User user = TempData["tempLoginUser"] as EnergyMonitor.Models.LinqEntity.User; string activeStr = Guid.NewGuid().ToString(); string webSiteName = "http://" + Request.Url.Authority; new Thread(delegate()//线程发送 { Util.SendActiveMail(webSiteName, user.USR_Mail, user.USR_ID, user.USR_Name, "/Homes/ActiveMail", activeStr); }).Start(); _userRepos.ModifyMail(user.USR_ID, user.USR_Mail, activeStr); return(View("ReactiveResult")); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { EnergyMonitor.Models.LinqEntity.User u = filterContext.HttpContext.Session["loginUser"] as EnergyMonitor.Models.LinqEntity.User; string actionName = filterContext.RouteData.Values["action"].ToString(); //验证是否管理员用户登录 if ((u == null || u.USR_RoleID == 1) && (!"GetSpecifiedBuildingEnergy".Equals(actionName)) && (!"GetElecAjaxForMobile".Equals(actionName)) && (!"GetHElecAjaxForMobile".Equals(actionName)) && (!"GetQueryElecAjaxForMobile".Equals(actionName)) && (!"GetHGElecListAjaxForMobile".Equals(actionName)) && (!"GetElecAllAjaxForMobile".Equals(actionName))) { if (!filterContext.HttpContext.Request.IsAjaxRequest()) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Homes", action = "NoLogin", Area = "" })); } else { filterContext.Result = new EmptyResult(); } } }
public ActionResult PersonalInfo() { EnergyMonitor.Models.LinqEntity.User loginUser = Session["loginUser"] as EnergyMonitor.Models.LinqEntity.User; if (loginUser != null) { ViewBag.userID = loginUser.USR_ID; ViewBag.userName = loginUser.USR_Name; ViewBag.userMail = loginUser.USR_Mail; ViewBag.userDepartName = loginUser.USR_DepartName; if (Session["userRoomInfo"] != null) { var list = Session["userRoomInfo"]; return(View(list)); } else { var list = _userRepos.GetUserRelatedRooms(loginUser.USR_ID); Session["userRoomInfo"] = list; return(View(list)); } } return(View()); }