Files App, get user's group after nextcloud authentication

Hi all,
I am wondering, can anyone point me on nextcloud, after authentication, when the File App is about to load, on which php code file can I access a authenticated user’s group and process a redirect based on that user’s group with a switch case php for instance ?

I saw on nextcloud API that is possible to get user’s session information
return $c->query(‘UserSession’)->getUser();

or using some king of function isInGroup($userId, $group);

and according to what is returned redirect that user to a URL automatically,
can anyone give me a direction on where can this code be written in the Files APP ?

thank you very much
Nuno