generic login routing middleware.