Skip to content

Instantly share code, notes, and snippets.

@simong
simong / email verification.md
Last active August 29, 2015 14:17
Email verification

Scenarios that touch upon email verification

  1. A user creates a new local user account
  2. A users comes in through SSO but has no email attribute
  3. A user updates his own email address
  4. Someone invites a guest via an email address
  5. ?

Some background around inviting guests

var mailUsersFromTenant = function(tenantAlias, callback) {
// Gets called for every 50 principals
var handlePrincipals = function(principals, next) {
// The `principals` set can contain groups, we just need the users
var users = _.filter(principals, function(principal) {
return PrincipalsUtil.isUser(principal.principalId);
});
// 3 model definitions
Furniture = define(...)
Wood = define(...)
Country = define(...)
// A 3-way join table between furniture and wood and country
FurnitureWood = define();
Furniture.hasMany(FurnitureeWood);
/**
* Mock the requests that the Passport library would make when verifying a user signing in through Google
*
* @param {String} email The user's email address
* @param {String} displayName The user's display name
*/
var mockGoogleSignInRequests = function(email, displayName) {
// Require nock inline as it messes with the HTTP stack
var nock = require('nock');
@simong
simong / test.js
Last active August 29, 2015 14:16
/**
* Test that verifies that leaving a group removes it from the membership library
*/
it('verify leaving a group removes it from the membership library', function(callback) {
TestsUtil.generateTestUsers(camAdminRestContext, 2, function(err, users, simon, nico) {
assert.ok(!err);
// Simon generates a test group that anyone can join
TestsUtil.generateTestGroups(simon.restContext, 1, function(group) {
Interesting telemetry points:
-----------------------------
Below are some questions I thought of that we might like to get
out of whatever system(s) that will back TimeTable.
Sign in
* Number of sign ins per month
* Number of unique users who signed in per month
* Number of sign ins per user per month
{ [SequelizeUniqueConstraintError]
name: 'SequelizeUniqueConstraintError',
message: undefined,
parent:
{ [error: duplicate key value violates unique constraint "Tenants_pkey"]
name: 'error',
length: 179,
severity: 'ERROR',
code: '23505',
detail: 'Key (id)=(1) already exists.',
@simong
simong / model.js
Last active August 29, 2015 14:07
// Models
var Tenant = sequelize.define('Tenant', {
'displayName': Sequelize.STRING
});
var App = sequelize.define('App', {
'displayName': Sequelize.STRING,
'hostname': Sequelize.STRING,
'type': {
'type': Sequelize.ENUM('timetable'),
@simong
simong / latest.sh
Created October 17, 2014 10:24
Sort your npm dependencies on when they were last published
#!/bin/sh
# Get all the non-git, non-oae modules
modules=$(npm ls --depth=0 | grep -v git | grep -v oae- | cut -f 2 -d ' ')
for module in $modules ; do
name=$(echo $module | cut -f 1 -d '@')
version=$(echo $module | cut -f 2 -d '@')
# Get the timestamp
echo $published=$(npm show $module | grep "'$version': '" | cut -f 4 -d "'") $module >> /tmp/published.txt
// Original at https://github.com/habeanf/annotator/blob/master/src/plugin/marginviewer.coffee
// Generated by CoffeeScript 1.7.1
(function() {
var clone,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
clone = function(obj) {
var key, newInstance;
if ((obj == null) || typeof obj !== 'object') {