diff --git a/public_html/js/Presenters/LoginPresenter.js b/public_html/js/Presenters/LoginPresenter.js
index 71df63c7..04fc7b56 100644
--- a/public_html/js/Presenters/LoginPresenter.js
+++ b/public_html/js/Presenters/LoginPresenter.js
@@ -14,13 +14,15 @@ App.Presenters.LoginPresenter = function(
var $el = jQuery('#content');
var $messages;
var template;
+ var previousRoute;
- function init() {
+ function init(args) {
topNavigationPresenter.select('login');
+ previousRoute = args.previousRoute;
promise.wait(util.promiseTemplate('login-form')).then(function(html) {
template = _.template(html);
if (auth.isLoggedIn()) {
- router.navigateToMainPage();
+ finishLogin();
} else {
render();
}
@@ -54,12 +56,20 @@ App.Presenters.LoginPresenter = function(
auth.loginFromCredentials(userNameOrEmail, password, remember)
.then(function(response) {
- router.navigateToMainPage();
+ finishLogin();
}).fail(function(response) {
messagePresenter.showError($messages, response.json && response.json.error || response);
});
}
+ function finishLogin() {
+ if (previousRoute && !previousRoute.match(/logout|password-reset|activate|register/)) {
+ router.navigate(previousRoute);
+ } else {
+ router.navigateToMainPage();
+ }
+ }
+
return {
init: init,
render: render,
diff --git a/public_html/js/Presenters/PagedCollectionPresenter.js b/public_html/js/Presenters/PagedCollectionPresenter.js
index c0e86916..3f441a69 100644
--- a/public_html/js/Presenters/PagedCollectionPresenter.js
+++ b/public_html/js/Presenters/PagedCollectionPresenter.js
@@ -49,7 +49,7 @@ App.Presenters.PagedCollectionPresenter = function(_, util, promise, api) {
if (typeof(failCallback) !== 'undefined') {
failCallback(response);
} else {
- console.log(Error(response.json && response.json.error || response));
+ console.log(new Error(response.json && response.json.error || response));
}
});
}
diff --git a/public_html/js/Presenters/UserActivationPresenter.js b/public_html/js/Presenters/UserActivationPresenter.js
index e909e778..767168b7 100644
--- a/public_html/js/Presenters/UserActivationPresenter.js
+++ b/public_html/js/Presenters/UserActivationPresenter.js
@@ -30,7 +30,6 @@ App.Presenters.UserActivationPresenter = function(
function reinit(args) {
operation = args.operation;
- console.log(operation);
promise.wait(util.promiseTemplate('user-query-form')).then(function(html) {
template = _.template(html);
if (args.token) {
diff --git a/public_html/js/Router.js b/public_html/js/Router.js
index a84a912b..921f98d8 100644
--- a/public_html/js/Router.js
+++ b/public_html/js/Router.js
@@ -42,7 +42,12 @@ App.Router = function(pathJs, _, jQuery, util, appState) {
function inject(path, presenterName, additionalParams) {
pathJs.map(path).to(function() {
- util.initContentPresenter(presenterName, _.extend(this.params, additionalParams));
+ var finalParams = _.extend(
+ this.params,
+ additionalParams,
+ {previousRoute: pathJs.routes.previous});
+
+ util.initContentPresenter( presenterName, finalParams);
});
}