Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Home page starts with an area, not a boring ol' singleton!
- Loading branch information
Tom Boutell
committed
Sep 28, 2016
1 parent
b2f0505
commit 0e927fd
Showing
7 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = { | ||
construct: function(self, options) { | ||
console.error('\n*** DANGER! *** YOU HAVE THE demo-autologin MODULE ENABLED!\n'); | ||
console.error('If you are not us, or running a public demo to which EVERYBODY'); | ||
console.error('should be INSTANTLY logged in AS ADMIN, remove the demo-autologin'); | ||
console.error('module folder and remove it from app.js too.'); | ||
console.error(''); | ||
console.error('(By the way, next time use the apostrophe-cli to make a much cleaner,'); | ||
console.error('smaller new project. Forking this sandbox is the hard way!)\n'); | ||
self.pageBeforeSend = function(req, callback) { | ||
if (!req.cookies.demo_autologin) { | ||
return self.apos.users.find({ username: 'admin' }).permission(false).toObject(function(err, user) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (!user) { | ||
return callback(null); | ||
} | ||
req.login(user, function(err) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
// Start a whole new request, but logged in. After this they | ||
// have the cookie so they can log out and back in normally if they want | ||
req.res.cookie('demo_autologin', 1); | ||
return req.res.redirect('/'); | ||
}); | ||
}); | ||
} | ||
return callback(null); | ||
}; | ||
} | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Borrowed from passport-local | ||
|
||
exports.lookup = function(obj, field) { | ||
if (!obj) { return null; } | ||
var chain = field.split(']').join('').split('['); | ||
for (var i = 0, len = chain.length; i < len; i++) { | ||
var prop = obj[chain[i]]; | ||
if (typeof(prop) === 'undefined') { return null; } | ||
if (typeof(prop) !== 'object') { return prop; } | ||
obj = prop; | ||
} | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters