Check user permission function