diff --git a/lib/client/client.js b/lib/client/client.js index 9c294dc..c3fea2a 100644 --- a/lib/client/client.js +++ b/lib/client/client.js @@ -51,18 +51,22 @@ AccountsTemplates.setPrevPath = function(newPath) { AccountsTemplates.ensureSignedIn = function(context, redirect) { if (!Meteor.userId()) { - AccountsTemplates.setState(AccountsTemplates.options.defaultState, function() { - var err = AccountsTemplates.texts.errors.mustBeLoggedIn; - AccountsTemplates.state.form.set("error", [err]); - }); + // if we're not already on an AT route + if (!_.contains(AccountsTemplates.knownRoutes, context.path)) { + + AccountsTemplates.setState(AccountsTemplates.options.defaultState, function() { + var err = AccountsTemplates.texts.errors.mustBeLoggedIn; + AccountsTemplates.state.form.set("error", [err]); + }); - // used after the signIn is submitted - AccountsTemplates.avoidDefaultRedirect = true; - AccountsTemplates.redirectToPrevPath = true; + // redirect settings + AccountsTemplates.avoidDefaultRedirect = true; + AccountsTemplates.redirectToPrevPath = true; - // redirect to defined sign-in route and then redirect back - // to original route after successful sign in - redirect('signIn'); + // redirect to defined sign-in route and then redirect back + // to original route after successful sign in + redirect('signIn'); + } } };