public JsonResult SaveProfile() { if (!Permission.LoginedNeed(Request, Response, Session)) { return(Json(false)); } User loginedUser = (User)Session["user"]; int uid = Convert.ToInt32(Request["id"]); log.Info("uid:" + loginedUser.uid + "正在保存用户uid:" + uid + "个人资料"); User user = UserView.GetUserById(uid); UserInfo info = UserInfoView.GetUserInfo(uid); if (loginedUser.rank == (int)UserRank.ADMINISTATOR) { user.rank = Convert.ToInt32(Request["rank"]); info.email = Request["email"]; } user.name = Request["nickname"]; info.sex = Request["sex"]; info.telephone = Request["telephone"]; info.address = Request["address"]; info.description = Request["description"]; info.birthday = Convert.ToDateTime(Request["birthday"]); return(Json(UserView.SaveUser(user) && UserInfoView.SaveUserInfo(info))); }
public ActionResult Edit(int id = 0) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User loginedUser = (User)Session["user"]; if (id == 0) { id = loginedUser.uid; } if (loginedUser.uid != id && loginedUser.rank != (int)UserRank.ADMINISTATOR) { Response.Redirect("/Index"); return(null); } User user = UserView.GetUserById(id); UserInfo info = UserInfoView.GetUserInfo(id); if (user == null || info == null) { Response.Redirect("/Index"); return(null); } ViewBag.loginedUser = loginedUser; ViewBag.user = user; ViewBag.info = info; return(View()); }
public new ActionResult Profile(int id = 0) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User loginedUser = (User)Session["user"]; if (id == 0) { id = loginedUser.uid; } User user = UserView.GetUserById(id); UserInfo info = UserInfoView.GetUserInfo(id); if (user == null || info == null) { Response.Redirect("/Index"); return(null); } ViewBag.loginedUser = loginedUser; ViewBag.user = user; ViewBag.info = info; return(View()); }
public ActionResult New(int id = 0) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User receiver = UserView.GetUserById(id); ViewBag.receiver = receiver; return(View()); }
public static User LoginWithCookie(HttpRequestBase request, HttpSessionStateBase session) { int uid = Convert.ToInt32(request.Cookies.Get("uid").Value); string password = request.Cookies.Get("password").Value; User user = UserView.GetUserById(uid); if (password == Encryption.PasswordCookieEncryption(request.UserHostAddress, user.password, user.login_date)) { log.Info("uid: " + user.uid + "以Cookie方式登录"); session["user"] = user; return(user); } return(null); }
public ActionResult Recover() { if (!Permission.NotLoginNeed(Request, Response, Session)) { return(null); } string code = Request.QueryString["code"]; User user = UserView.GetUserById(UserView.GetUIDByCode(code)); if (user == null) { Response.Redirect("/Index"); return(null); } ViewBag.user = user; ViewBag.code = code; return(View()); }
public JsonResult ResetPassword() { if (!Permission.NotLoginNeed(Request, Response, Session)) { return(Json(false)); } string code = Request["code"]; int uid = Convert.ToInt32(Request["uid"]); string password = Hash.SHA512(Request["password"]); User user = UserView.GetUserById(UserView.GetUIDByCode(code)); if (user.uid != uid) { return(Json(false)); } user.password = password; return(Json(UserView.SaveUser(user) && UserView.DeleteForgetPassword(code))); }