Handles redirection from login() and logout() correctly

This commit makes sure the user is redirected to the page he/she came from
before clicking on the 'login'/'logout' button.
Add the template of the email to in the configuration
Use the newly created email_to template from the configuration to send the emails