requireLogin not redirecting to login page I'm trying to get the following behavior, but it's not working:

If a user goes to http://example.com/addresses he should get redirected to the Craft login form. So the corresponding template has a {% requireLogin %} tag. After a successful login the user should be redirected to the page he was trying to access (in the case http://example.com/addresses)

Without any additions to the config array the redirect goes to http://example.com/login which is a 404 page.

If I add the loginPath setting to the config file and set it to 'admin/login' it redirects to the correct Craft login form, but after login it's not going to /addresses but /admin/addresses 

What settings would lead to the desired behavior?
You should create your /login template with a custom login form. If you do that, the redirect should work as expected:


  craft.session.returnUrl is set to the original URL that included the {% requireLogin %} tag that initiated the redirect to this login form.