Permalink
Browse files

added restricted access control

  • Loading branch information...
Jen Fong-Adwent
Jen Fong-Adwent committed Jul 30, 2012
1 parent b200dd7 commit 6006a04aa5473d694e12731732a556069ff2af03
Showing with 29 additions and 7 deletions.
  1. +1 −0 .gitignore
  2. +5 −0 public/stylesheets/main.css
  3. +18 −6 routes/auth.js
  4. +1 −1 views/layout.jade
  5. +4 −0 views/restricted.jade
View
@@ -1,3 +1,4 @@
.DS_Store
node_modules
local.json
+config/invitees.json
@@ -86,6 +86,10 @@ body {
width: 780px;
}
+.restricted .wrapper {
+ background-image: url('/locations/level4-detail.jpg');
+}
+
a {
outline: none;
text-decoration: none;
@@ -101,6 +105,7 @@ a {
#header .logo {
background-image: url('/logo.png');
background-repeat: no-repeat;
+ display: block;
width: 30px;
height: 30px;
}
View
@@ -1,24 +1,36 @@
var auth = require('../lib/authenticate');
var user = require('../lib/user');
+var invitees = require('../config/invitees');
module.exports = function(app, db, nconf, isLoggedIn) {
// Login
app.post('/login', function(req, res) {
auth.verify(req, nconf, function(error, email) {
if (email) {
- user.getStats(email, db, function(err, userStat) {
- for (var name in userStat) {
- req.session[name] = userStat[name];
- }
+ if (invitees[email]) {
+ user.getStats(email, db, function(err, userStat) {
+ for (var name in userStat) {
+ req.session[name] = userStat[name];
+ }
- res.redirect('/dashboard');
- });
+ res.redirect('/dashboard');
+ });
+ } else {
+ res.redirect('/restricted');
+ }
} else {
res.redirect('/');
}
});
});
+ app.get('/restricted', function(req, res) {
+ res.render('restricted', {
+ pageType: 'restricted',
+ title: 'You aren\'t on the Invite List :('
+ });
+ });
+
// Logout
app.get('/logout', isLoggedIn, function(req, res) {
req.session.destroy();
View
@@ -9,7 +9,7 @@ html
body(class='#{pageType}')
.wrapper
#header
- .logo
+ a.logo(href='/')
block content
View
@@ -0,0 +1,4 @@
+extend layout
+
+block content
+ h1= title

0 comments on commit 6006a04

Please sign in to comment.