Collections exteneded with PeerDB package for denormalized approach to data storage in MongoDB. Requires coffeescript
and peerdb
packages.
This file contains hidden or 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
RouteController.extend({ | |
before: function() { | |
if (_.isNull(Meteor.user()) && Router.current().route.name != 'loginPage') { | |
console.log("Redirect to login!"); | |
this.stop(); | |
Router.go('loginPage'); | |
} | |
} | |
}); |
This file contains hidden or 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
db.organisations.find({}).forEach(function(doc) { | |
doc.users = [ | |
{_id: doc.user} | |
]; | |
db.organisations.save(doc); | |
}); |
This file contains hidden or 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 collection is where the UserSession variables are ultimately stored | |
UserSessionCollection = new Meteor.Collection('userSessionCollection'); | |
// Anonymous user error | |
noUserError = function () { | |
console.log('You cannot use UserSession methods when there is no user logged in.'); | |
} | |
// Missing userId error | |
noUserIdError = function () { |
This file contains hidden or 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
Meteor.autorun(function() { | |
if (Meteor.user()) { | |
Meteor.logoutOtherClients(function(err) { | |
if (err) | |
console.log("Logout Error: " + err); | |
}); | |
console.log("login"); | |
} else { | |
console.log("logout"); | |
} |
This file contains hidden or 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
if (Meteor.isServer) { | |
Meteor.startup(function () { | |
process.env.MAIL_URL = 'smtp://username:[email protected]'; | |
Accounts.emailTemplates.siteName = "My Website Name"; | |
Accounts.emailTemplates.from = "My Website Name <[email protected]>"; | |
Accounts.emailTemplates.resetPassword.subject = function(user) { | |
return "How to reset your password for My Website Name"; |
This file contains hidden or 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
FixArrays = function(arrayObject) { | |
var temp = {}; | |
_.each(arrayObject , function(value, key, list) { | |
if (value instanceof Array) | |
if (value.length === 1) | |
temp[key] = value[0]; | |
else | |
temp[key] = value; |
OlderNewer