added beforeAuthentication and afterAuthentication middleware