From 4260d448bfdd2b4ec5af5ee6067db0752a8e03e0 Mon Sep 17 00:00:00 2001 From: Yaman Date: Sat, 31 Jan 2015 22:29:04 -0500 Subject: [PATCH] cleaned up and fixed redirect code --- chromebook-checkout-meteor/.meteor/versions | 2 +- chromebook-checkout-meteor/client/initial.js | 13 ++----------- chromebook-checkout-meteor/client/login.js | 9 +++++++++ chromebook-checkout-meteor/client/router.js | 15 ++++++++------- 4 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 chromebook-checkout-meteor/client/login.js diff --git a/chromebook-checkout-meteor/.meteor/versions b/chromebook-checkout-meteor/.meteor/versions index 532e668..3919f17 100644 --- a/chromebook-checkout-meteor/.meteor/versions +++ b/chromebook-checkout-meteor/.meteor/versions @@ -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 diff --git a/chromebook-checkout-meteor/client/initial.js b/chromebook-checkout-meteor/client/initial.js index eb13d6c..0fb7f42 100644 --- a/chromebook-checkout-meteor/client/initial.js +++ b/chromebook-checkout-meteor/client/initial.js @@ -15,15 +15,6 @@ Template.initial.events({ window.open(links[randomint], "_blank"); }, 'click .submit': function() { - Router.go('/checkout'); + Router.go('/login'); } -}) -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'); - } -}) +}) \ No newline at end of file diff --git a/chromebook-checkout-meteor/client/login.js b/chromebook-checkout-meteor/client/login.js new file mode 100644 index 0000000..22f8601 --- /dev/null +++ b/chromebook-checkout-meteor/client/login.js @@ -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'); + } +}) \ No newline at end of file diff --git a/chromebook-checkout-meteor/client/router.js b/chromebook-checkout-meteor/client/router.js index 20910f5..93e6267 100644 --- a/chromebook-checkout-meteor/client/router.js +++ b/chromebook-checkout-meteor/client/router.js @@ -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'); } }); \ No newline at end of file