added middleware for beforeJsapiAuthentication and afterJsapiAuthentication