<commit_before>Groups = new Mongo.Collection("groups");

Meteor.startup(function () {
	Meteor.publish('userScores', function () {
		return Meteor.users.find({}, {profile: {displayName: 1, subs: 1, rejs: 1, accs: 1, wds: 1, score: 1, groupId: 1}});
	});

	/// Email Verification nonsense cribbed from gentlenode.com
	Accounts.emailTemplates.from = 'Sink or Submit <<EMAIL>>';

	Accounts.emailTemplates.siteName = 'Sink or Submit';
	
	Accounts.emailTemplates.verifyEmail.subject = function (user) {
		return 'Confirm Your Email Address';
	};
	
	Accounts.emailTemplates.verifyEmail.text = function (user, url) {
		return 'Click the following link to verify your email address for Sink or Submit: ' + url;
	};

/*	Meteor.publish('groups', function () {
		return Groups.find(Meteor.user().groupId, {fields: {groupId: 1, groupDescription: 1}});
	});*/
});

Accounts.onCreateUser(function(options, user) {
	user.displayName = user.username;
	user.subs = 0;
	user.rejs = 0;
	user.accs = 0;
	user.wds = 0;
	user.score = 0;
	user.prevScore = 0;
	user.groupId = null;
  	user.groupAdmin = false;

	if (options.profile)
		user.profile = options.profile;

	Meteor.setTimeout(function () {
		Accounts.sendVerificationEmail(user._id);
	}, 2 * 1000);

	return user;
});

Accounts.validateLoginAttempt(function (attempt) {
	if (attempt.user && attempt.user.email && !attempt.user.emaills[0].verified ) {
		console.log('email not verified');

		return false;
	}

	return true;
});

Meteor.publish('userData', function() {
	if (!this.userId) return null;
	return Meteor.users.find(this.userId, {fields: {
		displayName: 1,
		subs: 1,
		rejs: 1,
		accs: 1,
		wds: 1,
		score: 1,
	  	groupId: 1,
	  	groupAdmin: 1}
	});
});

Meteor.publish("groups", function () {
	return Groups.find({}, {fields: {
		groupId: 1,
		groupDescription: 1,
		members: 1,
		admins: 1}<commit_msg>Email verification working. Need final styling for login buttons, but we have a product!<commit_after>Groups = new Mongo.Collection("groups");

Meteor.startup(function () {
	Meteor.publish('userScores', function () {
		return Meteor.users.find({}, {profile: {displayName: 1, subs: 1, rejs: 1, accs: 1, wds: 1, score: 1, groupId: 1}});
	});

	/// Email Verification nonsense cribbed from gentlenode.com
	Accounts.emailTemplates.from = 'Sink or Submit <<EMAIL>>';

	Accounts.emailTemplates.siteName = 'Sink or Submit';
	
	Accounts.emailTemplates.verifyEmail.subject = function (user) {
		return 'Confirm Your Email Address';
	};
	
	Accounts.emailTemplates.verifyEmail.text = function (user, url) {
		return 'Click the following link to verify your email address for Sink or Submit: ' + url;
	};

/*	Meteor.publish('groups', function () {
		return Groups.find(Meteor.user().groupId, {fields: {groupId: 1, groupDescription: 1}});
	});*/
});

Accounts.onCreateUser(function(options, user) {
	user.displayName = user.username;
	user.subs = 0;
	user.rejs = 0;
	user.accs = 0;
	user.wds = 0;
	user.score = 0;
	user.prevScore = 0;
	user.groupId = null;
  	user.groupAdmin = false;

	if (options.profile)
		user.profile = options.profile;

	Meteor.setTimeout(function () {
		Accounts.sendVerificationEmail(user._id);
	}, 2 * 1000);

	return user;
});

Accounts.validateLoginAttempt(function (attempt) {
	if (attempt.user && attempt.user.emails && !attempt.user.emails[0].verified ) {
		console.log('email not verified');

		return false;
	}

	return true;
});

Meteor.publish('userData', function() {
	if (!this.userId) return null;
	return Meteor.users.find(this.userId, {fields: {
		displayName: 1,
		subs: 1,
		rejs: 1,
		accs: 1,
		wds: 1,
		score: 1,
	  	groupId: 1,
	  	groupAdmin: 1}
	});
});

Meteor.publish("groups", function () {
	return Groups.find({}, {fields: {
		groupId: 1,
		groupDescription: 1,
		members: 1,
		admins: 1}
{'fraction_non_alphanumeric': 0.15630785506479766, 'fraction_numerical': 0.017455699550383497, 'mean_word_length': 4.202200825309491, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7448273', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1326, 'n_words': 322}