Fix current context logic issue in setpermissions