diff --git a/lms/templates/login_modal.html b/lms/templates/login_modal.html
index 1383cc0965..1587cca767 100644
--- a/lms/templates/login_modal.html
+++ b/lms/templates/login_modal.html
@@ -46,8 +46,9 @@
(function() {
$(document).delegate('#login_form', 'ajax:success', function(data, json, xhr) {
if(json.success) {
- if(getParameterByName('next')) {
- location.href = getParameterByName('next');
+ next = getParameterByName('next');
+ if(next) {
+ location.href = next;
} else {
location.href = "${reverse('dashboard')}";
}