{"action":"created","comment":{"url":"https://api.github.com/repos/oaeproject/Hilary/pulls/comments/32937483","id":32937483,"diff_hunk":"@@ -494,6 +534,64 @@ var _setLandingPageBlockAttribute = function(ctx, block, blockName, attributeNam\n ///////////////\n \n /**\n+ * Ensure that the given email domain does not conflict with any existing tenant domains. If this\n+ * validation is part of an update, the update tenant alias should be specified so that any conflict\n+ * in email domain with the tenant being updated can be ignored. Any validation errors will result\n+ * in the errors being added to the provided `validator`, therefore this does not `return` or\n+ * `throw` anything.\n+ *\n+ * @param  {Validator}  validator               The Validator object\n+ * @param  {String}     emailDomain             The email domain expression to verify\n+ * @param  {String}     [updateTenantAlias]     The alias of the tenant being updated, if any\n+ * @api private\n+ */\n+var _validateEmailDomain = function(validator, emailDomain, updateTenantAlias) {\n+    var matchingEmailDomain = _.chain(getTenants())\n+        .filter(function(tenant) {\n+            // If a tenant is being updated, don't try and match against its own existing email\n+            // domain\n+            return (tenant.alias !== updateTenantAlias);\n+        })\n+        .pluck('emailDomain')\n+        .compact()\n+        .filter(function(emailDomainExpr) {\n+            // There is a conflict if there is an existing expression that matches with the\n+            // expression, or vice versa\n+            return (_matchesEmailDomain(emailDomain, emailDomainExpr) ||\n+                _matchesEmailDomain(emailDomainExpr, emailDomain));\n+        })\n+        .first()\n+        .value();\n+\n+    validator.check(matchingEmailDomain, {\n+        'code': 400,\n+        'msg': util.format('The email domain \"%s\" conflicts with existing email domain: %s', emailDomain, matchingEmailDomain)\n+    }).isNull();\n+};\n+\n+/**\n+ * Determine if the given email domain expression matches the given email domain\n+ *\n+ * @param  {String}     emailDomain         The email domain to check\n+ * @param  {String}     emailDomainExpr     The email domain expression (e.g., *.cam.ac.uk)","path":"node_modules/oae-tenants/lib/api.js","position":288,"original_position":288,"commit_id":"0d57dc63212d480da3ebde6e249b6ccff3f75e4e","original_commit_id":"0d57dc63212d480da3ebde6e249b6ccff3f75e4e","user":{"login":"mrvisser","id":102265,"avatar_url":"https://avatars.githubusercontent.com/u/102265?v=3","gravatar_id":"","url":"https://api.github.com/users/mrvisser","html_url":"https://github.com/mrvisser","followers_url":"https://api.github.com/users/mrvisser/followers","following_url":"https://api.github.com/users/mrvisser/following{/other_user}","gists_url":"https://api.github.com/users/mrvisser/gists{/gist_id}","starred_url":"https://api.github.com/users/mrvisser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrvisser/subscriptions","organizations_url":"https://api.github.com/users/mrvisser/orgs","repos_url":"https://api.github.com/users/mrvisser/repos","events_url":"https://api.github.com/users/mrvisser/events{/privacy}","received_events_url":"https://api.github.com/users/mrvisser/received_events","type":"User","site_admin":false},"body":"Do you think there will be cases where a non-dotted suffix won't suffice?\r\n\r\nE.g., if there is a `*cam.ac.uk`, maybe there would be a `ucam.ac.uk` that is a completely differen't college\r\n\r\nIf so, we might want to consider either:\r\n\r\n* Support comma-separated domains: `cam.ac.uk,*.cam.ac.uk`\r\n* Have `*.cam.ac.uk` match both exactly `cam.ac.uk` and `*.cam.ac.uk` suffix matches\r\n\r\ncomma-separated is more explicit and flexible, but more verbose to configure. Both allow for appropriate conflict detection, though.","created_at":"2015-06-22T14:12:01Z","updated_at":"2015-06-22T14:12:01Z","html_url":"https://github.com/oaeproject/Hilary/pull/1202#discussion_r32937483","pull_request_url":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202","_links":{"self":{"href":"https://api.github.com/repos/oaeproject/Hilary/pulls/comments/32937483"},"html":{"href":"https://github.com/oaeproject/Hilary/pull/1202#discussion_r32937483"},"pull_request":{"href":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202"}}},"pull_request":{"url":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202","id":37652004,"html_url":"https://github.com/oaeproject/Hilary/pull/1202","diff_url":"https://github.com/oaeproject/Hilary/pull/1202.diff","patch_url":"https://github.com/oaeproject/Hilary/pull/1202.patch","issue_url":"https://api.github.com/repos/oaeproject/Hilary/issues/1202","number":1202,"state":"open","locked":false,"title":"(InvitingGuests/TenantDomains) Add ability specify an email domain expression for a tenant","user":{"login":"mrvisser","id":102265,"avatar_url":"https://avatars.githubusercontent.com/u/102265?v=3","gravatar_id":"","url":"https://api.github.com/users/mrvisser","html_url":"https://github.com/mrvisser","followers_url":"https://api.github.com/users/mrvisser/followers","following_url":"https://api.github.com/users/mrvisser/following{/other_user}","gists_url":"https://api.github.com/users/mrvisser/gists{/gist_id}","starred_url":"https://api.github.com/users/mrvisser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrvisser/subscriptions","organizations_url":"https://api.github.com/users/mrvisser/orgs","repos_url":"https://api.github.com/users/mrvisser/repos","events_url":"https://api.github.com/users/mrvisser/events{/privacy}","received_events_url":"https://api.github.com/users/mrvisser/received_events","type":"User","site_admin":false},"body":"Depends on oae-rest: oaeproject/oae-rest#20","created_at":"2015-06-15T00:54:02Z","updated_at":"2015-06-22T14:12:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee10b532983f379335be7e682fbb40975267ae72","assignee":{"login":"mrvisser","id":102265,"avatar_url":"https://avatars.githubusercontent.com/u/102265?v=3","gravatar_id":"","url":"https://api.github.com/users/mrvisser","html_url":"https://github.com/mrvisser","followers_url":"https://api.github.com/users/mrvisser/followers","following_url":"https://api.github.com/users/mrvisser/following{/other_user}","gists_url":"https://api.github.com/users/mrvisser/gists{/gist_id}","starred_url":"https://api.github.com/users/mrvisser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrvisser/subscriptions","organizations_url":"https://api.github.com/users/mrvisser/orgs","repos_url":"https://api.github.com/users/mrvisser/repos","events_url":"https://api.github.com/users/mrvisser/events{/privacy}","received_events_url":"https://api.github.com/users/mrvisser/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202/commits","review_comments_url":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202/comments","review_comment_url":"https://api.github.com/repos/oaeproject/Hilary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oaeproject/Hilary/issues/1202/comments","statuses_url":"https://api.github.com/repos/oaeproject/Hilary/statuses/0d57dc63212d480da3ebde6e249b6ccff3f75e4e","head":{"label":"mrvisser:tenant-domains","ref":"tenant-domains","sha":"0d57dc63212d480da3ebde6e249b6ccff3f75e4e","user":{"login":"mrvisser","id":102265,"avatar_url":"https://avatars.githubusercontent.com/u/102265?v=3","gravatar_id":"","url":"https://api.github.com/users/mrvisser","html_url":"https://github.com/mrvisser","followers_url":"https://api.github.com/users/mrvisser/followers","following_url":"https://api.github.com/users/mrvisser/following{/other_user}","gists_url":"https://api.github.com/users/mrvisser/gists{/gist_id}","starred_url":"https://api.github.com/users/mrvisser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrvisser/subscriptions","organizations_url":"https://api.github.com/users/mrvisser/orgs","repos_url":"https://api.github.com/users/mrvisser/repos","events_url":"https://api.github.com/users/mrvisser/events{/privacy}","received_events_url":"https://api.github.com/users/mrvisser/received_events","type":"User","site_admin":false},"repo":{"id":5658997,"name":"Hilary","full_name":"mrvisser/Hilary","owner":{"login":"mrvisser","id":102265,"avatar_url":"https://avatars.githubusercontent.com/u/102265?v=3","gravatar_id":"","url":"https://api.github.com/users/mrvisser","html_url":"https://github.com/mrvisser","followers_url":"https://api.github.com/users/mrvisser/followers","following_url":"https://api.github.com/users/mrvisser/following{/other_user}","gists_url":"https://api.github.com/users/mrvisser/gists{/gist_id}","starred_url":"https://api.github.com/users/mrvisser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrvisser/subscriptions","organizations_url":"https://api.github.com/users/mrvisser/orgs","repos_url":"https://api.github.com/users/mrvisser/repos","events_url":"https://api.github.com/users/mrvisser/events{/privacy}","received_events_url":"https://api.github.com/users/mrvisser/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrvisser/Hilary","description":"","fork":true,"url":"https://api.github.com/repos/mrvisser/Hilary","forks_url":"https://api.github.com/repos/mrvisser/Hilary/forks","keys_url":"https://api.github.com/repos/mrvisser/Hilary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrvisser/Hilary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrvisser/Hilary/teams","hooks_url":"https://api.github.com/repos/mrvisser/Hilary/hooks","issue_events_url":"https://api.github.com/repos/mrvisser/Hilary/issues/events{/number}","events_url":"https://api.github.com/repos/mrvisser/Hilary/events","assignees_url":"https://api.github.com/repos/mrvisser/Hilary/assignees{/user}","branches_url":"https://api.github.com/repos/mrvisser/Hilary/branches{/branch}","tags_url":"https://api.github.com/repos/mrvisser/Hilary/tags","blobs_url":"https://api.github.com/repos/mrvisser/Hilary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrvisser/Hilary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrvisser/Hilary/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrvisser/Hilary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrvisser/Hilary/statuses/{sha}","languages_url":"https://api.github.com/repos/mrvisser/Hilary/languages","stargazers_url":"https://api.github.com/repos/mrvisser/Hilary/stargazers","contributors_url":"https://api.github.com/repos/mrvisser/Hilary/contributors","subscribers_url":"https://api.github.com/repos/mrvisser/Hilary/subscribers","subscription_url":"https://api.github.com/repos/mrvisser/Hilary/subscription","commits_url":"https://api.github.com/repos/mrvisser/Hilary/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrvisser/Hilary/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrvisser/Hilary/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrvisser/Hilary/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrvisser/Hilary/contents/{+path}","compare_url":"https://api.github.com/repos/mrvisser/Hilary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrvisser/Hilary/merges","archive_url":"https://api.github.com/repos/mrvisser/Hilary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrvisser/Hilary/downloads","issues_url":"https://api.github.com/repos/mrvisser/Hilary/issues{/number}","pulls_url":"https://api.github.com/repos/mrvisser/Hilary/pulls{/number}","milestones_url":"https://api.github.com/repos/mrvisser/Hilary/milestones{/number}","notifications_url":"https://api.github.com/repos/mrvisser/Hilary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrvisser/Hilary/labels{/name}","releases_url":"https://api.github.com/repos/mrvisser/Hilary/releases{/id}","created_at":"2012-09-03T13:08:54Z","updated_at":"2014-06-23T16:51:00Z","pushed_at":"2015-06-22T12:11:30Z","git_url":"git://github.com/mrvisser/Hilary.git","ssh_url":"git@github.com:mrvisser/Hilary.git","clone_url":"https://github.com/mrvisser/Hilary.git","svn_url":"https://github.com/mrvisser/Hilary","homepage":null,"size":27208,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"oaeproject:master","ref":"master","sha":"77fd91e1e33399c1234585c5fcd15dc3d96cf53c","user":{"login":"oaeproject","id":4659912,"avatar_url":"https://avatars.githubusercontent.com/u/4659912?v=3","gravatar_id":"","url":"https://api.github.com/users/oaeproject","html_url":"https://github.com/oaeproject","followers_url":"https://api.github.com/users/oaeproject/followers","following_url":"https://api.github.com/users/oaeproject/following{/other_user}","gists_url":"https://api.github.com/users/oaeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/oaeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oaeproject/subscriptions","organizations_url":"https://api.github.com/users/oaeproject/orgs","repos_url":"https://api.github.com/users/oaeproject/repos","events_url":"https://api.github.com/users/oaeproject/events{/privacy}","received_events_url":"https://api.github.com/users/oaeproject/received_events","type":"Organization","site_admin":false},"repo":{"id":5638565,"name":"Hilary","full_name":"oaeproject/Hilary","owner":{"login":"oaeproject","id":4659912,"avatar_url":"https://avatars.githubusercontent.com/u/4659912?v=3","gravatar_id":"","url":"https://api.github.com/users/oaeproject","html_url":"https://github.com/oaeproject","followers_url":"https://api.github.com/users/oaeproject/followers","following_url":"https://api.github.com/users/oaeproject/following{/other_user}","gists_url":"https://api.github.com/users/oaeproject/gists{/gist_id}","starred_url":"https://api.github.com/users/oaeproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oaeproject/subscriptions","organizations_url":"https://api.github.com/users/oaeproject/orgs","repos_url":"https://api.github.com/users/oaeproject/repos","events_url":"https://api.github.com/users/oaeproject/events{/privacy}","received_events_url":"https://api.github.com/users/oaeproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oaeproject/Hilary","description":"Open Academic Environment (OAE) Back-End","fork":false,"url":"https://api.github.com/repos/oaeproject/Hilary","forks_url":"https://api.github.com/repos/oaeproject/Hilary/forks","keys_url":"https://api.github.com/repos/oaeproject/Hilary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oaeproject/Hilary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oaeproject/Hilary/teams","hooks_url":"https://api.github.com/repos/oaeproject/Hilary/hooks","issue_events_url":"https://api.github.com/repos/oaeproject/Hilary/issues/events{/number}","events_url":"https://api.github.com/repos/oaeproject/Hilary/events","assignees_url":"https://api.github.com/repos/oaeproject/Hilary/assignees{/user}","branches_url":"https://api.github.com/repos/oaeproject/Hilary/branches{/branch}","tags_url":"https://api.github.com/repos/oaeproject/Hilary/tags","blobs_url":"https://api.github.com/repos/oaeproject/Hilary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oaeproject/Hilary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oaeproject/Hilary/git/refs{/sha}","trees_url":"https://api.github.com/repos/oaeproject/Hilary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oaeproject/Hilary/statuses/{sha}","languages_url":"https://api.github.com/repos/oaeproject/Hilary/languages","stargazers_url":"https://api.github.com/repos/oaeproject/Hilary/stargazers","contributors_url":"https://api.github.com/repos/oaeproject/Hilary/contributors","subscribers_url":"https://api.github.com/repos/oaeproject/Hilary/subscribers","subscription_url":"https://api.github.com/repos/oaeproject/Hilary/subscription","commits_url":"https://api.github.com/repos/oaeproject/Hilary/commits{/sha}","git_commits_url":"https://api.github.com/repos/oaeproject/Hilary/git/commits{/sha}","comments_url":"https://api.github.com/repos/oaeproject/Hilary/comments{/number}","issue_comment_url":"https://api.github.com/repos/oaeproject/Hilary/issues/comments{/number}","contents_url":"https://api.github.com/repos/oaeproject/Hilary/contents/{+path}","compare_url":"https://api.github.com/repos/oaeproject/Hilary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oaeproject/Hilary/merges","archive_url":"https://api.github.com/repos/oaeproject/Hilary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oaeproject/Hilary/downloads","issues_url":"https://api.github.com/repos/oaeproject/Hilary/issues{/number}","pulls_url":"https://api.github.com/repos/oaeproject/Hilary/pulls{/number}","milestones_url":"https://api.github.com/repos/oaeproject/Hilary/milestones{/number}","notifications_url":"https://api.github.com/repos/oaeproject/Hilary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oaeproject/Hilary/labels{/name}","releases_url":"https://api.github.com/repos/oaeproject/Hilary/releases{/id}","created_at":"2012-09-01T10:05:13Z","updated_at":"2015-05-06T15:17:28Z","pushed_at":"2015-06-22T12:11:31Z","git_url":"git://github.com/oaeproject/Hilary.git","ssh_url":"git@github.com:oaeproject/Hilary.git","clone_url":"https://github.com/oaeproject/Hilary.git","svn_url":"https://github.com/oaeproject/Hilary","homepage":"http://www.oaeproject.org","size":29980,"stargazers_count":32,"watchers_count":32,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":65,"mirror_url":null,"open_issues_count":29,"forks":65,"open_issues":29,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202"},"html":{"href":"https://github.com/oaeproject/Hilary/pull/1202"},"issue":{"href":"https://api.github.com/repos/oaeproject/Hilary/issues/1202"},"comments":{"href":"https://api.github.com/repos/oaeproject/Hilary/issues/1202/comments"},"review_comments":{"href":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202/comments"},"review_comment":{"href":"https://api.github.com/repos/oaeproject/Hilary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oaeproject/Hilary/pulls/1202/commits"},"statuses":{"href":"https://api.github.com/repos/oaeproject/Hilary/statuses/0d57dc63212d480da3ebde6e249b6ccff3f75e4e"}}}}