Token has_perm fix (rebased)