private bool SignIn(string name, string pwd, string orgId, OrgType orgType) { NCI_User user = null; if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(pwd) && UserCheck(name, pwd, orgId, orgType, ref user)) { IAuthenticationService authenticationService = IOCContainer.Instance.Resolve <IAuthenticationService>(); ClientUserData clientUserData = new ClientUserData() { UserId = user.UserId, UserIdInt = user.UserId, Account = user.Account, UserName = user.UserName, OrgId = orgId,// 超级管理员可能登陆进入不同Org, 因此这里用登陆选择的ORG. RoleType = user.RoleType, OrgType = (int)orgType, RoleId = user.RoleId, LoginName = user.Account, GovId = user.BelongToGovId }; authenticationService.SignIn(clientUserData, true); return(true); } return(false); }
private bool CheckIsSuperAdmin(NCI_User user) { //检查是否是超级管理员,只有超级管理员可以登入所有机构. var userRoleResponse = userService.GetRole(user.RoleId); if (userRoleResponse == null || userRoleResponse.Data == null) { return(false); } var userRole = userRoleResponse.Data; return(userRole.RoleType == EnumRoleType.SuperAdmin.ToString()); }
public ActionResult Index(string userId) { var userInfo = new NCI_User(); userInfo.UserName = SecurityHelper.CurrentPrincipal.UserName; userInfo.UserId = SecurityHelper.CurrentPrincipal.UserId; userInfo.OrgType = SecurityHelper.CurrentPrincipal.OrgType; userInfo.OrgId = SecurityHelper.CurrentPrincipal.OrgId; TempData["OrgType"] = userInfo.OrgType; ViewBag.User = userInfo; //ViewBag.Notifications = NotificationList(userInfo.UserId.ToString()); //ViewBag.Messages = MessageList(userInfo.UserId.ToString()); //ViewBag.Tasks = TaskList(userInfo.UserId.ToString()); return(View("index")); }
public bool userCheck(string name, string pwd, string orgId, ref NCI_User user) { IOrganizationManageService service = IOCContainer.Instance.Resolve <IOrganizationManageService>(); BaseRequest <NCI_UserFilter> request = new BaseRequest <NCI_UserFilter>(); request.Data.Account = name; request.Data.Password = pwd; request.Data.OrgId = orgId; var userList = service.QueryUser(request); if (userList.Data.Count > 0) { user = userList.Data[0]; } return(userList.Data.Count > 0); }
public IHttpActionResult Post(NCI_User user) { if (user.UserId == 0) { if (user.OrgId == null) { user.OrgId = SecurityHelper.CurrentPrincipal.OrgId; user.OrgType = SecurityHelper.CurrentPrincipal.OrgType; } user.ParentUserId = SecurityHelper.CurrentPrincipal.UserId; user.CreateBy = SecurityHelper.CurrentPrincipal.UserId.ToString(); user.CreateTime = DateTime.Now; } else { user.UpdateBy = SecurityHelper.CurrentPrincipal.UserId.ToString(); user.UpdateTime = DateTime.Now; } var response = usersService.SaveUser(user); return(Ok(response)); }
private bool UserCheck(string name, string pwd, string orgId, OrgType orgType, ref NCI_User user) { //TODO 添加更丰富的返回信息,给予失败提示 pwd = Util.Encryption(pwd); var userQueryResponse = userService.QueryUserByAccount(name); if (userQueryResponse == null || userQueryResponse.Data == null) { return(false); } var stroedUser = userQueryResponse.Data; if (stroedUser.Password != pwd) { return(false); } if (stroedUser.Status != (int)AccountStatus.Enable) { return(false); } var isSuperAdmin = false; if (stroedUser.OrgId != orgId && !(isSuperAdmin = CheckIsSuperAdmin(stroedUser))) { return(false); } if (stroedUser.OrgId != orgId || stroedUser.OrgType != (int)orgType) { if (!(isSuperAdmin = CheckIsSuperAdmin(stroedUser)))//非超级管理员,只能登陆本机构. { return(false); } } var request = new BaseRequest <NCI_UserFilter> { Data = { Account = name, Password = pwd } }; if (!isSuperAdmin) { request.Data.OrgId = orgId; } //TODO 改进逻辑,在最初就获取UserExtend对象. var userList = userService.QueryUserExtend(request); if (userList.Data.Count > 0) { user = userList.Data[0]; } return(userList.Data.Count > 0); }
public BaseResponse <NCI_User> SaveUser(NCI_User request) { return(base.Save <NCI_USER, NCI_User>(request, (q) => q.USERID == request.UserId)); }