Skip to content

Commit

Permalink
don't redirect to login if already on an AT route
Browse files Browse the repository at this point in the history
  • Loading branch information
jshimko committed Aug 10, 2015
1 parent ef29c61 commit aa83215
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
};

Expand Down

0 comments on commit aa83215

Please sign in to comment.