cleaned up and fixed redirect code

This commit is contained in:
Yaman 2015-01-31 22:29:04 -05:00
parent d2b12ae8c1
commit 4260d448bf
4 changed files with 20 additions and 19 deletions

View File

@ -55,7 +55,7 @@ oauth@1.1.3
oauth2@1.1.2
observe-sequence@1.0.4
ordered-dict@1.0.2
percolate:momentum@0.7.1
percolate:momentum@0.7.0
percolate:velocityjs@1.1.0
random@1.0.2
reactive-dict@1.0.5

View File

@ -15,15 +15,6 @@ Template.initial.events({
window.open(links[randomint], "_blank");
},
'click .submit': function() {
Router.go('/checkout');
}
})
Template.login.events({
'click .chromeicon': function() {
var randomint = Math.floor(Math.random() * (links.length - 1));
window.open(links[randomint], "_blank");
},
'click .submit': function() {
Router.go('/checkout');
Router.go('/login');
}
})

View File

@ -0,0 +1,9 @@
Template.login.events({
'click .chromeicon': function() {
var randomint = Math.floor(Math.random() * (links.length - 1));
window.open(links[randomint], "_blank");
},
'click .submit': function() {
Router.go('/login');
}
})

View File

@ -1,4 +1,4 @@
Router.route('/', function() {
Router.route('/', function() {
this.render("initial");
})
@ -15,12 +15,13 @@ Router.route('/login', function() {
this.redirect('/teacher');
} else if (Roles.userIsInRole(Meteor.userId(), ['admin'])) {
this.redirect('/admin');
} else if (Roles.userIsInRole(Meteor.userId(), ['admin', 'teacher'])) {
this.redirect('/admin');
} else if (Meteor.user()) {
this.redirect('/checkout');
} else {
this.render("login");
if (Meteor.loggingIn()) {
Router.redirect('/login')
}
else {
this.redirect('/checkout');
};
}
});
@ -36,6 +37,6 @@ Router.route('/teacher', function() {
if (Roles.userIsInRole(Meteor.userId(), ['admin', 'teacher'])) {
this.render("teacher");
} else {
this.redirect('/login');
this.redirect('/login');
}
});