Ejemplo n.º 1
0
 public IActionResult Login(string userName, string pwd)
 {
     if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(pwd))
     {
         var entity = _personAppService.GetPersonByPassWord(userName, pwd);
         if (entity != null)
         {
             var tokeninfo = GenerateToken(userName);
             _userTokenAppService.SaveUserToken(token: tokeninfo);
             return(Ok(new
             {
                 data = tokeninfo
             }));
         }
         else
         {
             return(BadRequest(new
             {
                 message = "用户名或密码错误"
             }));
         }
     }
     else
     {
         return(BadRequest(new { message = "username or password is incorrect." }));
     }
 }