public IActionResult NewUserOrg(int id, string uid)
        {
            var usrids = uid.Split(',');

            foreach (var idstr in usrids)
            {
                sys_user sysUser = _sysUserRpt.GetSingle(int.Parse(idstr));
                if (sysUser != null)
                {
                    sysUser.OrgId = id;
                }
            }
            _sysUserRpt.Commit();
            return(new NoContentResult());
        }
        public IActionResult Login([FromBody] sys_user user)
        {
            //User existUser = UserStorage.Users.FirstOrDefault(u => u.Username == user.Username && u.Password == user.Password);
            var existUser =
                _sysUserRpt.GetSingle(f => f.UserId == user.UserId && f.Pwd == user.Pwd);

            if (existUser != null)
            {
                existUser.LastLoginTime = DateTime.Now;
                _sysUserRpt.Commit();

                var requestAt = DateTime.Now;
                var expiresIn = requestAt + TokenAuthOption.ExpiresSpan;
                var token     = GenerateToken(existUser, expiresIn);

                return(Json(new RequestResult
                {
                    State = RequestState.Success,
                    Data = new
                    {
                        requertAt = requestAt,
                        expiresIn = TokenAuthOption.ExpiresSpan.TotalSeconds,
                        tokeyType = TokenAuthOption.TokenType,
                        accessToken = token
                    }
                }));
            }
            return(Json(new RequestResult
            {
                State = RequestState.Failed,
                Msg = "Óû§Ãû»òÃÜÂë´íÎó¡£"
            }));
        }
示例#3
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="Account"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public SysUser LoginValidate(string Account, string Password)
        {
            Password = DESEncrypt.Encrypt(Password);
            var expression = LinqExtensions.True <SysUser>();

            if (!string.IsNullOrEmpty(Account))
            {
                expression = expression.And(t => t.Account == Account);
            }
            if (!string.IsNullOrEmpty(Account))
            {
                expression = expression.And(t => t.Password == Password);
            }
            var model = _sysUserRepository.GetSingle(expression);

            return(model);
        }
示例#4
0
        public IActionResult GetMenu()
        {
            var    _menusVM = _sysMenuRpt.FindBy(f => f.IsValid).OrderBy(f => f.MenuOrder).ToList();
            string userId   = string.Empty;

            if (User.Identity is ClaimsIdentity identity)
            {
                userId = identity.Name ?? "admin";
            }
            var user = _sysUserRepository.GetSingle(f => f.UserId == userId);

            if (userId == "admin" || user == null)
            {
                return(Get());
            }
            var        roleUser = _sysRoleUserRepository.FindBy(f => f.UserId == user.Id).ToList();
            List <int> roleId   = new List <int>();

            foreach (var ru in roleUser)
            {
                roleId.Add(ru.RoleId);
            }
            var roleM        = _sysRoleMenuRpt.GetAll().ToList();
            var roleMenuList = new List <sys_role_menu>();

            foreach (var ri in roleId)
            {
                roleMenuList.AddRange(roleM.FindAll(f => f.RoleId == ri));
            }

            List <sys_menu> sys_menuList = new List <sys_menu>();

            foreach (var mv in _menusVM)
            {
                if (roleMenuList.Exists(f => f.MenuId == mv.Id))
                {
                    sys_menuList.Add(mv);
                }
            }
            return(new OkObjectResult(sys_menuList));;
        }
示例#5
0
        public async Task <IActionResult> Get(string userId)
        {
            var single = _sysUserRpt.GetSingle(f => f.UserId == userId);

            return(new OkObjectResult(single));
        }