+ referer = request.META.get('HTTP_REFERER', '/')
+
+ # If the referer is equal to the sign up page, e. g. if the previous login attempt was not successful we do not
+ # change the sign in URL. The user should go to the same page.
+ if not referer.replace(settings.APP_URL, '') == reverse('auth_signin'):
+ request.session[ON_SIGNIN_SESSION_ATTR] = referer