public IActionResult Auth([FromBody] AuthRequest request) { try { var user = _service.Authenticate(request.Login, request.Password); string token = TokenGenerator.GenerateToken(_jwtSettings.Secret, user.Id.ToString()); return(Ok(new AuthResponse { Token = token })); } catch (InvalidParamsError) { return(StatusCode(StatusCodes.Status400BadRequest, new { message = "Логин и пароль обязательны для ввода" })); } catch (UserNotExistError) { return(StatusCode(StatusCodes.Status404NotFound, new { message = "Пользователь не найден" })); } catch (VerifyPasswordError) { return(StatusCode(StatusCodes.Status400BadRequest, new { message = "Неверный пароль" })); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, new { message = e.Message })); } }