Пример #1
0
        public async Task <ResultMessage> Login(LoginModel model, JwtTokenModel jwtToken)
        {
            var user = await business.GetUser(model.Account);

            if (null != user)
            {
                if (user.Password != SecretHelper.Md532(model.Password))
                {
                    return(new ResultMessage()
                    {
                        Status = "0", Message = "密码错误"
                    });
                }
                return(new ResultMessage()
                {
                    Status = "1", Response = JWTHelper.GenerateToken(user, jwtToken)
                });
            }
            else
            {
                return(new ResultMessage()
                {
                    Status = "0", Message = "用户名错误"
                });
            }
        }
Пример #2
0
        public async Task <ResultMessage> AddAsync(User_Info userInfo)
        {
            //var user = await busines.GetUser(model.Account, model.Password);
            var user = await business.GetUser(userInfo.Account);

            if (null != user)
            {
                return(new ResultMessage()
                {
                    Status = "0", Message = "用户名已存在"
                });
            }
            userInfo.Password = SecretHelper.Md532(userInfo.Password);
            return(new ResultMessage()
            {
                Status = await business.AddAsync(userInfo) ? "1" : "0"
            });
        }