public ApiMessage VerifyPassword() { ApiMessage message = new ApiMessage() { Status = "ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; int uid = 0; try { int.TryParse(request["uid"], out uid); SystemAdmin admin = new SystemAdmin(int.Parse(user_id)); string password = request["password"]; if (!admin.VerifyPassword(password, uid)) { message.Status = "failed"; message.Message = "旧密码输入错误"; } } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } return message; }
public ApiMessage SetCorpInfo() { ApiMessage message = new ApiMessage() { Status="ok" }; HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; try { SystemAdmin admin = new SystemAdmin(int.Parse(user_id)); Corp_Info info = new Corp_Info() { About=request["about"],Contact=request["contact"],Help=request["help"] }; admin.SetCorpInfo(info); } catch (KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } return message; }
public static SystemAdmin Login(string name, string password) { SystemAdmin adminInstance = null; using (KuanMaiEntities db = new KuanMaiEntities()) { User user = (from u in db.User where u.IsSystemUser == true && u.Name == name select u).FirstOrDefault<User>(); if (user == null) { throw new KMJXCException("用户名不存在"); } string md5Password = Encrypt.MD5(password); if (md5Password != user.Password) { throw new KMJXCException("密码不正确"); } adminInstance = new SystemAdmin(user.User_ID); } return adminInstance; }
public static SystemAdmin Login(string name, string password) { SystemAdmin adminInstance = null; using (KuanMaiEntities db = new KuanMaiEntities()) { User user = (from u in db.User where u.IsSystemUser == true && u.Name == name select u).FirstOrDefault <User>(); if (user == null) { throw new KMJXCException("用户名不存在"); } string md5Password = Encrypt.MD5(password); if (md5Password != user.Password) { throw new KMJXCException("密码不正确"); } adminInstance = new SystemAdmin(user.User_ID); } return(adminInstance); }
public ActionResult Password() { string user = HttpContext.User.Identity.Name; SystemAdmin admim = new SystemAdmin(int.Parse(user)); return View(admim.CurrentUser); }