Permission check bug fix

* When the permission is first checked, write it to the req also for
checking permissions
* Fix a bug where an exception is not thrown properly, resulting in the
server stopping