Пример #1
0
 public ActionResult <LoginResponse> Index([FromForm] string username, [FromForm] string password)
 {
     if (username == TestAdminUser.Username && password == TestAdminUser.Password)
     {
         var token = _jwtEncoder.CreateToken(TestAdminUser);
         return(new LoginResponse
         {
             Username = username,
             AuthToken = token,
             Roles = TestAdminUser.Roles
         });
     }
     if (username == TestReadonlyUser.Username && password == TestReadonlyUser.Password)
     {
         var token = _jwtEncoder.CreateToken(TestReadonlyUser);
         return(new LoginResponse
         {
             Username = username,
             AuthToken = token,
             Roles = TestReadonlyUser.Roles
         });
     }
     return(NotFound($"User {username} not exits or wrong password"));
 }