public UserInfo SignUp(SignUpUserInfo userInfo) { DbModel.UserInfo usr = _repository.SignUp(userInfo.WorkId, userInfo.UserName, userInfo.Password, userInfo.RoleId, userInfo.Remark); if (usr == null) { return(null); } UserInfo user = new UserInfo(); user.Id = usr.Id; user.WorkId = usr.WorkId; user.UserName = usr.UserName; user.Password = usr.Password; user.RoleId = usr.RoleId; user.Role = _roleApp.Load(user.RoleId); user.Remark = usr.Remark; return(user); }
public IActionResult SignUp([FromForm] SignUpUserInfo userInfo) { if (ModelState.IsValid) { UserInfo usr = _userApp.SignUp(userInfo); if (usr != null) { return(RedirectToAction(nameof(Index))); } ModelState.AddModelError("DbError", "注册失败!请稍后再试!"); } IQueryable <RoleInfo> roles = _roleApp.Query(); //如果登录的不是超管就不允许创建管理员账户 UserInfo currentUsr = HttpContext.Session.Get("Neko_Asp_User").ToObject <UserInfo>(); if (currentUsr.Role.RoleType != RoleType.Admin) { roles = roles.Where(p => p.RoleType != RoleType.Admin); } ViewBag.Roles = new SelectList(roles, "RoleId", "RoleName"); ViewBag.IsEdit = false; return(View(userInfo)); }