Permission based withPageAuth

Hi, I'm trying to restrict certain pages to users meeting a certain criteria. I've got 'withPageAuth' working for logged in users and I've read that if you use middleware you can check the user's email if it ends in a certain domain.

I can't get this to work as it allows all logged in users and it not restricting. I'm not using typescript so is that the issue? I'm not getting any errors so any help would be much appreciated. Thanks in advance.
Was this page helpful?