How to make Parse server login — case insensitive?

I have Parse server with MongoDB and KMP app where login method.

@POST("login")
@Headers(
    value = [
        "${ParseHeaders.CONTENT_TYPE}: application/json",
        "${ParseHeaders.APPLICATION_ID}: ${ParseConstants.APPLICATION_ID}",
        "${ParseHeaders.REST_API_KEY}: ${ParseConstants.REST_API_KEY}",
    ],
)
suspend fun logIn(@Body credentials: ParseLoginCredentials): ParseUserResponse

I need to make the username case-insensitive. Currently, usernames are stored in MongoDB in a disorganized way. We need to structure this on the server side, so the login username in the Parse server must be case-insensitive. I don’t see any login functions in the Parse backend code, yet the login works for some reason. Perhaps it’s handled internally by Parse. I’ve written an interceptor in the Parse server code, but it’s not working.

app.post('/login', function(req, res) {
  let fs = require('fs');
  let path = require('path');
  let bodyParser = require('body-parser');

  app.use(bodyParser.json());

  const { username, password } = req.body;

  if (!username || !password) {
    return res.status(400).send('Username and password are required');
  }

  const lowercasedUsername = username.toLowerCase();
  const loginRequest = new Parse.Query(Parse.User);
  loginRequest.equalTo("username", lowercasedUsername);

  loginRequest.first().then(function(user) {
    if (user) {
      const userStoredUsername = user.get("username").toLowerCase();

      if (userStoredUsername === lowercasedUsername) {
        user.authenticate(password).then(function(isAuthenticated) {
          if (isAuthenticated) {
            res.status(200).json({
              objectId: user.id,
              sessionToken: user.getSessionToken(),
            });
          } else {
            res.status(401).send('Invalid credentials');
          }
        }).catch(function(err) {
          res.status(500).send('Error authenticating user: ' + err.message);
        });
      } else {
        res.status(401).send('Invalid credentials');
      }
    } else {
      res.status(401).send('Invalid credentials');
    }
  }).catch(function(err) {
    res.status(500).send('Error finding user: ' + err.message);
  });
});

Is there any option to handle this on the MongoDB side? Or how can it be done with Parse Server? Do I need to write additional code, such as a case-insensitive login hook, or is there another solution?

I also tried modifying and hiding some indexes in the `_User` entity on MongoDB, but it had no effect.
enter image description here