public dynamic GetUsers() { return(HashTool.verify("12345", "$2a$10$ayRGdkzRo/i3/DuE8AIqhOpNtRZaYnxdCVpRd3AkZrr.Pg4jkOLde")); }
//public dynamic Postusers(dynamic data) public dynamic userLogin(FormUsersLogin data) { //return ModelState.ToArray(); List <string> errList = new List <string>(); if (!db.users.Any(o => o.email == data.email)) { errList.Add("emailNotExistErr"); return(JsonTool.toJson(errList)); } foreach (ModelState modelState in ModelState.Values) { foreach (ModelError error in modelState.Errors) { errList.Add(error.ErrorMessage.ToString()); } } if (errList.Count > 0) { return(JsonTool.toJson(errList)); } var user = (from p in db.users where p.email == data.email select p).SingleOrDefault(); int status = (int)user.status; if (status == -1) { errList.Add("userBannedErr"); return(JsonTool.toJson(errList)); } if (status == 0) { errList.Add("userNotActivateErr"); return(JsonTool.toJson(errList)); } string hash = user.password; if (!HashTool.verify(data.password, hash)) { errList.Add("passwordInCorrectErr"); return(JsonTool.toJson(errList)); } var obj = ( from p in db.users where p.email == data.email select new { p.userID, p.email, p.nickname, p.gender, p.birthDate, p.createAt, p.updateAt } ).SingleOrDefault(); return(JsonTool.toJson(obj)); }