If it’s based on v3 it’s not going to be compatible, this code you have looks like middleware, so question is you want to append middleware to user permissions?
If it’s based on v3 it’s not going to be compatible, this code you have looks like middleware, so question is you want to append middleware to user permissions?