From 5ba92d597d7a7acb11ba60fc175fa47d945f2302 Mon Sep 17 00:00:00 2001 From: Yaman Date: Thu, 1 Jan 2015 02:20:24 -0500 Subject: [PATCH] Added /admin --- chromebook-checkout-meteor/client/admin.html | 8 +++++ .../client/chromebook.js | 8 +++++ chromebook-checkout-meteor/client/router.js | 30 ++++++++++++------- 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 chromebook-checkout-meteor/client/admin.html diff --git a/chromebook-checkout-meteor/client/admin.html b/chromebook-checkout-meteor/client/admin.html new file mode 100644 index 0000000..d44cab5 --- /dev/null +++ b/chromebook-checkout-meteor/client/admin.html @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/chromebook-checkout-meteor/client/chromebook.js b/chromebook-checkout-meteor/client/chromebook.js index 217d880..c48a267 100644 --- a/chromebook-checkout-meteor/client/chromebook.js +++ b/chromebook-checkout-meteor/client/chromebook.js @@ -38,4 +38,12 @@ Template.chromebook.events({ Chromebooks.update(this._id, {$set: {userid: null}}); } } + 'click .cross': function() { + if (Roles.userIsInRole(Meteor.userId(), ['admin'])) { + Router.go('/admin'); + } + else { + alert("Access Denied"); + } + } }); \ No newline at end of file diff --git a/chromebook-checkout-meteor/client/router.js b/chromebook-checkout-meteor/client/router.js index 0149b42..f3eba60 100644 --- a/chromebook-checkout-meteor/client/router.js +++ b/chromebook-checkout-meteor/client/router.js @@ -1,19 +1,27 @@ Router.route('/', function() { - this.render("initial"); + this.render("initial"); }) Router.route('/checkout', function() { - if (Meteor.user()) { - this.render("checkout"); - } else { - this.redirect('/login'); - } + if (Meteor.user()) { + this.render("checkout"); + } else { + this.redirect('/login'); + } }); Router.route('/login', function() { - if (Meteor.user()) { - this.redirect('/checkout'); - } else { - this.render("login"); - } + if (Meteor.user()) { + this.redirect('/checkout'); + } else { + this.render("login"); + } +}); + +Router.route('/admin', function() { + if (Meteor.user().roles[0]==='admin') { + this.render("admin"); + } else { + this.redirect('/checkout'); + } }); \ No newline at end of file