public IActionResult EditMe() { Core.Admin my = Core.Admin.GetMyInfo(); Core.Admin.WriteLogActions("查看/编辑我的信息;"); ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength); return(View(my)); }
public IActionResult DelAdmin(int id) { Core.Admin entity = Core.Admin.Find(Core.Admin._.Id == id); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } Core.Admin my = Core.Admin.GetMyInfo(); if (entity.Id == my.Id) { tip.Message = "您不可以删除自己!"; return(Json(tip)); } //如果是普通管理员,不能删除超级管理员 if (entity.Roles.IsSuperAdmin == 1 && my.Roles.IsSuperAdmin != 1) { tip.Message = "您不可以删除超级管理员!"; return(Json(tip)); } Core.Admin.WriteLogActions($"删除管理员(id:{entity.Id};usernmae:{entity.UserName});"); entity.Delete(); tip.Status = JsonTip.SUCCESS; tip.Message = "删除管理员成功"; return(Json(tip)); }
public IActionResult DelAdminRole(int id) { AdminRoles entity = AdminRoles.Find(AdminRoles._.Id == id); if (entity == null) { tip.Message = "系统找不到本管理组详情!"; return(Json(tip)); } if (entity.NotAllowDel == 1) { tip.Message = "本管理组设定不允许删除,如果需要删除,请先解除限制!"; return(Json(tip)); } //如果不是超级管理员,不允许删除 Core.Admin my = Core.Admin.GetMyInfo(); if (my.Roles.IsSuperAdmin != 1) { tip.Message = "非超级管理员,不能执行此操作!"; return(Json(tip)); } //如果只有一个管理组,不允许删除! if (AdminRoles.FindCount(null, null, null, 0, 0) == 1) { tip.Message = "只有一个管理组,不能删除!"; return(Json(tip)); } //删除管理组,并删除旗下所有管理员 Core.Admin.WriteLogActions($"执行删除管理组({entity.Id}:{entity.RoleName})详情;"); entity.Delete(); tip.Status = JsonTip.SUCCESS; tip.Message = "删除管理组成功"; return(Json(tip)); }
public IActionResult AddAdmin(IFormCollection fc) { string userName = fc["UserName"]; string newPwd = fc["PassWord"]; string renewPwd = fc["PassWord2"]; string roleid = fc["RoleId"]; string realname = fc["RealName"]; if (!Utils.IsInt(roleid)) { tip.Message = "请选择一个管理组!"; return(Json(tip)); } if (string.IsNullOrEmpty(userName)) { tip.Message = "登录用户名不能为空!"; return(Json(tip)); } if (Utils.GetStringLength(userName.Trim()) < 5) { tip.Message = "登录用户名不能小于5个字节!"; return(Json(tip)); } if (string.IsNullOrEmpty(newPwd)) { tip.Message = "密码不能为空!"; return(Json(tip)); } if (newPwd.Length < 5) { tip.Message = "密码不能小于5个字符!"; return(Json(tip)); } if (newPwd != renewPwd) { tip.Message = "两次输入密码不一致,请重新输入!"; return(Json(tip)); } //验证用户名 if (Core.Admin.FindCount(Core.Admin._.UserName == userName, null, null, 0, 0) > 0) { tip.Message = "该用户名已经存在,请选择其他用户名!"; return(Json(tip)); } Core.Admin entity = new Core.Admin(); entity.UserName = userName; entity.RealName = realname; entity.Salt = Utils.GetRandomChar(10); entity.PassWord = Utils.MD5(entity.Salt + newPwd); entity.RoleId = int.Parse(roleid); entity.Insert(); tip.Status = JsonTip.SUCCESS; tip.Message = "添加管理员成功!"; tip.ReturnUrl = "close"; Core.Admin.WriteLogActions($"添加新管理员({entity.UserName});"); return(Json(tip)); }
private void Logon(Core.Admin entity) { FillSession(entity); if (entity.RememberMe) { SetCookie(); } }
private bool HasCookie() { CookieManager Cookie = new CookieManager(); int AdminId; if (int.TryParse(Cookie.Read(CookieManager.CookieType.AdminId), out AdminId)) { Core.Admin entity = repository.GetById(AdminId); FillSession(entity); SetCookie(); return(true); } return(false); }
public IActionResult EditAdmin(int id) { //加载管理组 IList <AdminRoles> list = AdminRoles.FindAll(AdminRoles._.Id > 0, AdminRoles._.Rank.Asc(), null, 0, 0); ViewBag.RoleList = list; Core.Admin entity = Core.Admin.Find(Core.Admin._.Id == id); if (entity == null) { return(EchoTipPage("系统找不到本记录!")); } Core.Admin.WriteLogActions($"查看/编辑管理员({entity.UserName});"); return(View(entity)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Admin = await _context.Admins.FirstOrDefaultAsync(m => m.Id == id); if (Admin == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Admin = await _context.Admins.FindAsync(id); if (Admin != null) { _context.Admins.Remove(Admin); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public ActionResult Form(Core.Admin entity) { try { List <string> RequestValues = null; if (Request.Form["chAuth"] != null) { RequestValues = new List <string>(Request.Form["chAuth"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } service.SaveWithPermission(entity, adminAuthService, RequestValues); return(PartialResultSuccess()); } catch (Exception) { return(PartialResultError()); } }
public IActionResult EditAdmin(IFormCollection fc) { string userName = fc["UserName"]; string newPwd = fc["PassWord"]; string renewPwd = fc["PassWord2"]; string roleid = fc["RoleId"]; string realname = fc["RealName"]; string Id = fc["Id"]; if (!Utils.IsInt(Id)) { tip.Message = "错误参数传递!"; return(Json(tip)); } Core.Admin entity = Core.Admin.Find(Core.Admin._.Id == int.Parse(Id)); if (entity == null) { tip.Message = "系统找不到本记录!"; return(Json(tip)); } if (!Utils.IsInt(roleid)) { tip.Message = "请选择一个管理组!"; return(Json(tip)); } if (string.IsNullOrEmpty(userName)) { tip.Message = "登录用户名不能为空!"; return(Json(tip)); } if (Utils.GetStringLength(userName.Trim()) < 5) { tip.Message = "登录用户名不能小于5个字节!"; return(Json(tip)); } if (entity.UserName != userName)//修改用户名 { //验证用户名是否存在 if (Core.Admin.FindCount(Core.Admin._.Id != entity.Id & Core.Admin._.UserName == userName, null, null, 0, 0) > 0) { tip.Message = "该用户名已经存在,请选择其他用户名!"; return(Json(tip)); } entity.UserName = userName; } if (!string.IsNullOrEmpty(newPwd))//修改密码 { if (newPwd.Length < 5) { tip.Message = "密码不能小于5个字符!"; return(Json(tip)); } if (newPwd != renewPwd) { tip.Message = "两次输入密码不一致,请重新输入!"; return(Json(tip)); } entity.PassWord = Utils.MD5(entity.Salt + newPwd); } entity.RoleId = int.Parse(roleid); entity.RealName = realname; entity.Update(); tip.Status = JsonTip.SUCCESS; tip.Message = "修改管理员信息成功!"; tip.ReturnUrl = "close"; Core.Admin.WriteLogActions($"修改新管理员({entity.Id}:{entity.UserName});"); return(Json(tip)); }
public IActionResult EditMe(IFormCollection fc) { Core.Admin my = Core.Admin.GetMyInfo(); string userName = fc["UserName"]; string oldPwd = fc["txtOldPwd"]; string newPwd = fc["txtNewPwd"]; string renewPwd = fc["txtreNewPwd"]; string realname = fc["RealName"]; string tel = fc["Tel"]; string email = fc["Email"]; string editor = fc["Editor"]; if (!Utils.IsInt(editor)) { editor = "0"; } //判断 if (string.IsNullOrWhiteSpace(userName)) { tip.Message = "用户名不能为空!"; return(Json(tip)); } userName = userName.Trim(); if (Utils.GetStringLength(userName) < 5) { tip.Message = "用户名不能小于5个字符!"; return(Json(tip)); } if (!string.IsNullOrEmpty(email) && !Utils.IsValidEmail(email)) { tip.Message = "请填写正确的Email地址!"; return(Json(tip)); } if (userName != my.UserName)//修改用户名 { if (Core.Admin.FindCount(Core.Admin._.UserName == userName.Trim() & Core.Admin._.Id != my.Id, null, null, 0, 0) > 0) { tip.Message = "新用户名在已经存在,请选择其他用户名!"; return(Json(tip)); } my.UserName = userName.Trim(); } if (!string.IsNullOrEmpty(newPwd)) { //修改密码的情况 if (string.IsNullOrWhiteSpace(oldPwd) || oldPwd.Length < 5) { tip.Message = "您修改密码,旧密码不能为空!"; return(Json(tip)); } if (newPwd.Length < 5) { tip.Message = "新密码不能小于5个字符!"; return(Json(tip)); } if (newPwd != renewPwd) { tip.Message = "您输入的两次密码不一样!"; return(Json(tip)); } //判断旧密码是否正确 if (my.PassWord != Utils.MD5(my.Salt + oldPwd.Trim())) { tip.Message = "您输入的旧密码不正确,请重新输入!"; return(Json(tip)); } my.PassWord = Utils.MD5(my.Salt + newPwd); } tip.Message = "测试版暂时屏蔽修改密码,敬请原谅!"; return(Json(tip)); //my.Tel = tel; //my.Email = email; //my.RealName = realname; //my.Update(); //Core.Admin.WriteLogActions("修改我的信息;"); //tip.Status = JsonTip.SUCCESS; //tip.Message = "编辑我的信息成功!"; //return Json(tip); }
public IActionResult EditMe() { Core.Admin my = Core.Admin.GetMyInfo(); Core.Admin.WriteLogActions("查看/编辑我的信息;"); return(View(my)); }