Authenticates a user and generates a JWT token for them.

  • Parameters

    • req: Request

      The Express request object.

    • res: Response

      The Express response object.

    • next: (err?: null | Error) => void

      The next middleware function.

    • newUsername: string

      The new username for the user.

    Returns void