Confusion over 'require login' behavior
By default Craft checks the postLoginRedirect setting in your config. Depending on this value the user is going to be redirected to certain place. But if there is a value in the user session that's set when the requireLogin function is called Yii2 will use this value instead. So the workflow is the following


Check for a session value, if there is one, redirect the user
Check for postLoginRedirect value, if there is one, redirect the user
Redirect to homepage



  Using a return parameter in the login form does not work for obvious reasons.


Could you explain those obvious reasons? Because I always use the returnUrl from UsersController when I create a login via ajax.

You don't have to do anything actually. Just include the Twig token and Yii2 will handle it