fix token has_perm
Easy hack
Merge pull request #657 from drkitty/token_has_perm2

Token has_perm handler (rebased)