@@ 1,5 1,6 @@
import functools
+from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import HttpResponseRedirect
from django.utils.deprecation import MiddlewareMixin
from django.utils.functional import SimpleLazyObject
@@ 29,5 30,9 @@ class OTPCheckMiddleware(OTPMiddleware,
else:
return None
if request.path not in settings.NLOTP_VERIFY_EXCLUDED_URLS:
- return HttpResponseRedirect(settings.NLOTP_VERIFY_URL)
+ next_url = request.GET.get(REDIRECT_FIELD_NAME)
+ return HttpResponseRedirect(
+ '{0}?{1}={2}'.format(settings.NLOTP_VERIFY_URL,
+ REDIRECT_FIELD_NAME, next_url)
+ )
return None