コード例 #1
0
 public IActionResult Login(LoginViewModel model)
 {
     if (ModelState.IsValid)
     {
         var emp = _employeesManage.Login(model.Email, model.PassWord, out Guid empId);
         if (emp == true)
         {
             return(Ok(new EndState()
             {
                 Data = JwtFactory.GetToken(new Claim[]
                 {
                     new Claim("Email", model.Email),
                     new Claim("PassWord", model.PassWord),
                 }),
                 IsSucceed = true,
                 ErrorMessage = "登录成功"
             }));
         }
         return(Ok(new EndState()
         {
             Code = 500, IsSucceed = false, ErrorMessage = "账号密码错误"
         }));
     }
     return(Ok(new EndState()
     {
         Code = 500, IsSucceed = false, ErrorMessage = "校验未通过"
     }));
 }