public AdminUserLoginInfo Authenticate(LoginInputDto input) { if (string.IsNullOrEmpty(input.LoginUserName)) { throw new ArgumentNullException("LoginUserName"); } if (string.IsNullOrEmpty(input.Password)) { throw new ArgumentNullException("Password"); } //根据账号和密码取得用户信息 var adminUserInfo = adminUserRepository.GetAll(u => u.UserName == input.LoginUserName).FirstOrDefault(); /*检查用户登录 * --是户名是否存在 * --密码是否匹配 * --用户是否被锁定 */ CheckLoginCondition(adminUserInfo, input); //获取用户拥有的角色列表 var userRoleList = adminUserRepository.GetRoles(adminUserInfo.Id); if (!adminUserInfo.IsSuperAdmin && userRoleList.Count() == 0) { throw new UnauthorizedAccessException(); } var adminUserLoginInfo = new AdminUserLoginInfo() { Roles = userRoleList, User = adminUserInfo }; return(adminUserLoginInfo); }
public WhereModel ManagementRange(Int64 userId) { var whereModel = new WhereModel() { RoleId = 0, PhoneNumber = string.Empty, Province = "0", City = "0", Region = "0", StartTime = DateTime.Now, EndTime = DateTime.Now }; var str_startTime = Request["StartTime"]; var str_endTime = Request["EndTime"]; DateTime startTime = DateTime.Now; DateTime endTime = DateTime.Now; if (string.IsNullOrEmpty(str_startTime) || !DateTime.TryParse(str_startTime, out startTime)) { startTime = DateTime.Now.AddMonths(-3); } if (string.IsNullOrEmpty(str_endTime) || !DateTime.TryParse(str_endTime, out endTime)) { endTime = DateTime.Now; } whereModel.StartTime = startTime; whereModel.EndTime = endTime; if (this.UserInfo.IsSuperAdmin) { return(whereModel);//如果是超级管理员 直接 弹出, } var UserId = userId; var roleList = adminUserRepository.GetRoles(UserId); if (roleList.Any(role => role.RoleID == (int)RoleType.Admin)) { return(whereModel);//如果是管理员 直接 弹出, } var bo = false; foreach (var role in roleList) { if (role.RoleID == (int)RoleType.Dealer) { bo = true; } } if (bo) { var suppliers_SareaModel = suppliers_SareaRespository.GetManageArea(UserId); var list = new List <string>(); if (suppliers_SareaModel != null && suppliers_SareaModel.Count > 0)//判断是否有管理区域 { for (int i = 0; i < suppliers_SareaModel.Count; i++) { list.Add(suppliers_SareaModel[i].AID); } } whereModel.SuppliersWhere = list; if (whereModel.SuppliersWhere.Count == 0) { list.Add("aaa"); } return(whereModel); } return(null); }