Esempio n. 1
0
        public string Login(string mobile, string password)
        {
            var returnData = new ReturnData();

            if (!string.IsNullOrEmpty(mobile) && !string.IsNullOrEmpty(password))
            {
                var userId = AccountBll.Login(mobile, password);
                if (!string.IsNullOrEmpty(userId))
                {
                    returnData.UserId        = userId.ToString();
                    returnData.Status        = "OK";
                    returnData.StatusContent = "登录成功";
                }
                else
                {
                    returnData.Status        = "FAIL";
                    returnData.StatusContent = "登录失败,请检查您的用户名和密码。";
                }
            }
            else
            {
                returnData.Status        = "PARAERROR";
                returnData.StatusContent = "参数错误";
            }
            return(_javaScriptSerializer.Serialize(returnData));
        }
Esempio n. 2
0
        public IHttpActionResult Login([FromBody] UserLoginModel user)
        {       // If model is Invalid return failed login.
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (AccountBll.Login(user))
            {
                var jwtservice = new JWTService();
                var jwtmodel   = JWTModel.GetJWTContainerModel(user.Email);
                var token      = jwtservice.GenerateToken(jwtmodel);
                var dict       = new Dictionary <string, string>();
                dict.Add("token", token);
                return(Content(HttpStatusCode.OK, dict, new JsonMediaTypeFormatter()));
            }
            return(Content(HttpStatusCode.BadRequest, new MessageStatus()
            {
                Code = "500", Message = "Login Failed"
            },
                           new JsonMediaTypeFormatter()));
        }
Esempio n. 3
0
 public Employees Login(string name, string pwd)
 {
     return(AccountBll.Login(name, pwd));
 }