Exemplo n.º 1
0
        public HttpResult Login(LoginInfo item)
        {
            if (item == null || string.IsNullOrEmpty(item.UserName) || string.IsNullOrEmpty(item.Password))
            {
                return(new HttpResult {
                    RetCode = 1, Message = "User Name or Password can't be empty!"
                });
            }

            User user = repo.GetByName(item.UserName);

            if (user == null)
            {
                return(new HttpResult {
                    RetCode = 1, Message = "Login failed, no such user!"
                });
            }
            else if (!user.Password.Equals(item.Password))
            {
                return(new HttpResult {
                    RetCode = 1, Message = "Login failed, password is incorrect!"
                });
            }
            else
            {
                return(new HttpResult {
                    RetCode = 0, Message = "Login succeed!"
                });
            }
        }