Refactored if-statements in middleware.
Automatically attach authenticity token to iframe form submission.