{"action":"created","comment":{"url":"https://api.github.com/repos/wekan/wekan/pulls/comments/46654508","id":46654508,"diff_hunk":"@@ -107,6 +133,75 @@ Meteor.methods({\n   },\n });\n \n+if (Meteor.isServer) {\n+  Meteor.methods({\n+    inviteUserToBoard(username, boardId) {\n+      check(username, String);\n+      check(boardId, String);\n+\n+      const inviter = Meteor.user();\n+      const board = Boards.findOne(boardId);\n+      const allowInvite = inviter &&\n+          board &&\n+          board.members &&\n+          _.contains(_.pluck(board.members, 'userId'), inviter._id) &&\n+          _.where(board.members, {userId: inviter._id})[0].isActive &&\n+          _.where(board.members, {userId: inviter._id})[0].isAdmin;\n+      if (!allowInvite) throw new Meteor.Error('error-board-notAdmin');\n+\n+      this.unblock();\n+\n+      const posAt = username.indexOf('@');\n+      let user = Users.findOne((posAt >= 0) ? {emails: {$elemMatch: {address: username}}} : { username });\n+      if (user) {\n+        if (user._id === inviter._id) throw new Meteor.Error('error-user-notAllowSelf');\n+      } else {\n+        if (posAt <= 0) throw new Meteor.Error('error-user-doesNotExist');\n+\n+        const email = username;\n+        username = email.substring(0, posAt);\n+        const newUserId = Accounts.createUser({ username, email });\n+        if (!newUserId) throw new Meteor.Error('error-user-notCreated');\n+        // assume new user speak same language with inviter\n+        if (inviter.profile && inviter.profile.language) {\n+          Users.update(newUserId, {\n+            $set: {\n+              'profile.language': inviter.profile.language,\n+            },\n+          });\n+        }\n+        Accounts.sendEnrollmentEmail(newUserId);\n+        user = Users.findOne(newUserId);\n+      }\n+\n+      board.addMember(user._id);\n+      user.addInvite(boardId);\n+\n+      try {\n+        const rootUrl = process.env.ROOT_URL || '';","path":"models/users.js","position":89,"original_position":89,"commit_id":"e88eb7504ea173a097f0697d7b04ea4a67d674c0","original_commit_id":"e88eb7504ea173a097f0697d7b04ea4a67d674c0","user":{"login":"mquandalle","id":1730702,"avatar_url":"https://avatars.githubusercontent.com/u/1730702?v=3","gravatar_id":"","url":"https://api.github.com/users/mquandalle","html_url":"https://github.com/mquandalle","followers_url":"https://api.github.com/users/mquandalle/followers","following_url":"https://api.github.com/users/mquandalle/following{/other_user}","gists_url":"https://api.github.com/users/mquandalle/gists{/gist_id}","starred_url":"https://api.github.com/users/mquandalle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mquandalle/subscriptions","organizations_url":"https://api.github.com/users/mquandalle/orgs","repos_url":"https://api.github.com/users/mquandalle/repos","events_url":"https://api.github.com/users/mquandalle/events{/privacy}","received_events_url":"https://api.github.com/users/mquandalle/received_events","type":"User","site_admin":false},"body":"I think it better to read it from `Meteor.absoluteUrl.defaultOptions.rootUrl` than from the `process.env`","created_at":"2015-12-04T07:07:56Z","updated_at":"2015-12-04T07:07:56Z","html_url":"https://github.com/wekan/wekan/pull/422#discussion_r46654508","pull_request_url":"https://api.github.com/repos/wekan/wekan/pulls/422","_links":{"self":{"href":"https://api.github.com/repos/wekan/wekan/pulls/comments/46654508"},"html":{"href":"https://github.com/wekan/wekan/pull/422#discussion_r46654508"},"pull_request":{"href":"https://api.github.com/repos/wekan/wekan/pulls/422"}}},"pull_request":{"url":"https://api.github.com/repos/wekan/wekan/pulls/422","id":52488259,"html_url":"https://github.com/wekan/wekan/pull/422","diff_url":"https://github.com/wekan/wekan/pull/422.diff","patch_url":"https://github.com/wekan/wekan/pull/422.patch","issue_url":"https://api.github.com/repos/wekan/wekan/issues/422","number":422,"state":"open","locked":false,"title":"add: invite new user to board via email","user":{"login":"floatinghotpot","id":2339512,"avatar_url":"https://avatars.githubusercontent.com/u/2339512?v=3","gravatar_id":"","url":"https://api.github.com/users/floatinghotpot","html_url":"https://github.com/floatinghotpot","followers_url":"https://api.github.com/users/floatinghotpot/followers","following_url":"https://api.github.com/users/floatinghotpot/following{/other_user}","gists_url":"https://api.github.com/users/floatinghotpot/gists{/gist_id}","starred_url":"https://api.github.com/users/floatinghotpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floatinghotpot/subscriptions","organizations_url":"https://api.github.com/users/floatinghotpot/orgs","repos_url":"https://api.github.com/users/floatinghotpot/repos","events_url":"https://api.github.com/users/floatinghotpot/events{/privacy}","received_events_url":"https://api.github.com/users/floatinghotpot/received_events","type":"User","site_admin":false},"body":"Currently, we can only add user existing in system to our board. \r\n\r\nHere introduce a way to invite new user to join the board by sending invitation email. The new user will be created and added to the board, but no password is set. The new user has to click the link in enrollment email to set initial password.\r\n\r\nThis feature will enhance social interaction.","created_at":"2015-12-03T03:39:02Z","updated_at":"2015-12-04T07:07:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d732e9a9590dd4b49f394526e07d02d6f377b77a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wekan/wekan/pulls/422/commits","review_comments_url":"https://api.github.com/repos/wekan/wekan/pulls/422/comments","review_comment_url":"https://api.github.com/repos/wekan/wekan/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wekan/wekan/issues/422/comments","statuses_url":"https://api.github.com/repos/wekan/wekan/statuses/e88eb7504ea173a097f0697d7b04ea4a67d674c0","head":{"label":"floatinghotpot:patch-7","ref":"patch-7","sha":"e88eb7504ea173a097f0697d7b04ea4a67d674c0","user":{"login":"floatinghotpot","id":2339512,"avatar_url":"https://avatars.githubusercontent.com/u/2339512?v=3","gravatar_id":"","url":"https://api.github.com/users/floatinghotpot","html_url":"https://github.com/floatinghotpot","followers_url":"https://api.github.com/users/floatinghotpot/followers","following_url":"https://api.github.com/users/floatinghotpot/following{/other_user}","gists_url":"https://api.github.com/users/floatinghotpot/gists{/gist_id}","starred_url":"https://api.github.com/users/floatinghotpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floatinghotpot/subscriptions","organizations_url":"https://api.github.com/users/floatinghotpot/orgs","repos_url":"https://api.github.com/users/floatinghotpot/repos","events_url":"https://api.github.com/users/floatinghotpot/events{/privacy}","received_events_url":"https://api.github.com/users/floatinghotpot/received_events","type":"User","site_admin":false},"repo":{"id":45410538,"name":"wekan","full_name":"floatinghotpot/wekan","owner":{"login":"floatinghotpot","id":2339512,"avatar_url":"https://avatars.githubusercontent.com/u/2339512?v=3","gravatar_id":"","url":"https://api.github.com/users/floatinghotpot","html_url":"https://github.com/floatinghotpot","followers_url":"https://api.github.com/users/floatinghotpot/followers","following_url":"https://api.github.com/users/floatinghotpot/following{/other_user}","gists_url":"https://api.github.com/users/floatinghotpot/gists{/gist_id}","starred_url":"https://api.github.com/users/floatinghotpot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floatinghotpot/subscriptions","organizations_url":"https://api.github.com/users/floatinghotpot/orgs","repos_url":"https://api.github.com/users/floatinghotpot/repos","events_url":"https://api.github.com/users/floatinghotpot/events{/privacy}","received_events_url":"https://api.github.com/users/floatinghotpot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/floatinghotpot/wekan","description":"The open-source Trello-like kanban","fork":true,"url":"https://api.github.com/repos/floatinghotpot/wekan","forks_url":"https://api.github.com/repos/floatinghotpot/wekan/forks","keys_url":"https://api.github.com/repos/floatinghotpot/wekan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/floatinghotpot/wekan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/floatinghotpot/wekan/teams","hooks_url":"https://api.github.com/repos/floatinghotpot/wekan/hooks","issue_events_url":"https://api.github.com/repos/floatinghotpot/wekan/issues/events{/number}","events_url":"https://api.github.com/repos/floatinghotpot/wekan/events","assignees_url":"https://api.github.com/repos/floatinghotpot/wekan/assignees{/user}","branches_url":"https://api.github.com/repos/floatinghotpot/wekan/branches{/branch}","tags_url":"https://api.github.com/repos/floatinghotpot/wekan/tags","blobs_url":"https://api.github.com/repos/floatinghotpot/wekan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/floatinghotpot/wekan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/floatinghotpot/wekan/git/refs{/sha}","trees_url":"https://api.github.com/repos/floatinghotpot/wekan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/floatinghotpot/wekan/statuses/{sha}","languages_url":"https://api.github.com/repos/floatinghotpot/wekan/languages","stargazers_url":"https://api.github.com/repos/floatinghotpot/wekan/stargazers","contributors_url":"https://api.github.com/repos/floatinghotpot/wekan/contributors","subscribers_url":"https://api.github.com/repos/floatinghotpot/wekan/subscribers","subscription_url":"https://api.github.com/repos/floatinghotpot/wekan/subscription","commits_url":"https://api.github.com/repos/floatinghotpot/wekan/commits{/sha}","git_commits_url":"https://api.github.com/repos/floatinghotpot/wekan/git/commits{/sha}","comments_url":"https://api.github.com/repos/floatinghotpot/wekan/comments{/number}","issue_comment_url":"https://api.github.com/repos/floatinghotpot/wekan/issues/comments{/number}","contents_url":"https://api.github.com/repos/floatinghotpot/wekan/contents/{+path}","compare_url":"https://api.github.com/repos/floatinghotpot/wekan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/floatinghotpot/wekan/merges","archive_url":"https://api.github.com/repos/floatinghotpot/wekan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/floatinghotpot/wekan/downloads","issues_url":"https://api.github.com/repos/floatinghotpot/wekan/issues{/number}","pulls_url":"https://api.github.com/repos/floatinghotpot/wekan/pulls{/number}","milestones_url":"https://api.github.com/repos/floatinghotpot/wekan/milestones{/number}","notifications_url":"https://api.github.com/repos/floatinghotpot/wekan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/floatinghotpot/wekan/labels{/name}","releases_url":"https://api.github.com/repos/floatinghotpot/wekan/releases{/id}","created_at":"2015-11-02T17:33:32Z","updated_at":"2015-11-10T03:48:22Z","pushed_at":"2015-12-04T04:15:17Z","git_url":"git://github.com/floatinghotpot/wekan.git","ssh_url":"git@github.com:floatinghotpot/wekan.git","clone_url":"https://github.com/floatinghotpot/wekan.git","svn_url":"https://github.com/floatinghotpot/wekan","homepage":"http://wekan.io","size":1085,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"cn-dev"}},"base":{"label":"wekan:devel","ref":"devel","sha":"d4c5310d65cbdfbd002288d33eba429ace33bc3c","user":{"login":"wekan","id":11725037,"avatar_url":"https://avatars.githubusercontent.com/u/11725037?v=3","gravatar_id":"","url":"https://api.github.com/users/wekan","html_url":"https://github.com/wekan","followers_url":"https://api.github.com/users/wekan/followers","following_url":"https://api.github.com/users/wekan/following{/other_user}","gists_url":"https://api.github.com/users/wekan/gists{/gist_id}","starred_url":"https://api.github.com/users/wekan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wekan/subscriptions","organizations_url":"https://api.github.com/users/wekan/orgs","repos_url":"https://api.github.com/users/wekan/repos","events_url":"https://api.github.com/users/wekan/events{/privacy}","received_events_url":"https://api.github.com/users/wekan/received_events","type":"Organization","site_admin":false},"repo":{"id":16089035,"name":"wekan","full_name":"wekan/wekan","owner":{"login":"wekan","id":11725037,"avatar_url":"https://avatars.githubusercontent.com/u/11725037?v=3","gravatar_id":"","url":"https://api.github.com/users/wekan","html_url":"https://github.com/wekan","followers_url":"https://api.github.com/users/wekan/followers","following_url":"https://api.github.com/users/wekan/following{/other_user}","gists_url":"https://api.github.com/users/wekan/gists{/gist_id}","starred_url":"https://api.github.com/users/wekan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wekan/subscriptions","organizations_url":"https://api.github.com/users/wekan/orgs","repos_url":"https://api.github.com/users/wekan/repos","events_url":"https://api.github.com/users/wekan/events{/privacy}","received_events_url":"https://api.github.com/users/wekan/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wekan/wekan","description":"The open-source Trello-like kanban","fork":false,"url":"https://api.github.com/repos/wekan/wekan","forks_url":"https://api.github.com/repos/wekan/wekan/forks","keys_url":"https://api.github.com/repos/wekan/wekan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wekan/wekan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wekan/wekan/teams","hooks_url":"https://api.github.com/repos/wekan/wekan/hooks","issue_events_url":"https://api.github.com/repos/wekan/wekan/issues/events{/number}","events_url":"https://api.github.com/repos/wekan/wekan/events","assignees_url":"https://api.github.com/repos/wekan/wekan/assignees{/user}","branches_url":"https://api.github.com/repos/wekan/wekan/branches{/branch}","tags_url":"https://api.github.com/repos/wekan/wekan/tags","blobs_url":"https://api.github.com/repos/wekan/wekan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wekan/wekan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wekan/wekan/git/refs{/sha}","trees_url":"https://api.github.com/repos/wekan/wekan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wekan/wekan/statuses/{sha}","languages_url":"https://api.github.com/repos/wekan/wekan/languages","stargazers_url":"https://api.github.com/repos/wekan/wekan/stargazers","contributors_url":"https://api.github.com/repos/wekan/wekan/contributors","subscribers_url":"https://api.github.com/repos/wekan/wekan/subscribers","subscription_url":"https://api.github.com/repos/wekan/wekan/subscription","commits_url":"https://api.github.com/repos/wekan/wekan/commits{/sha}","git_commits_url":"https://api.github.com/repos/wekan/wekan/git/commits{/sha}","comments_url":"https://api.github.com/repos/wekan/wekan/comments{/number}","issue_comment_url":"https://api.github.com/repos/wekan/wekan/issues/comments{/number}","contents_url":"https://api.github.com/repos/wekan/wekan/contents/{+path}","compare_url":"https://api.github.com/repos/wekan/wekan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wekan/wekan/merges","archive_url":"https://api.github.com/repos/wekan/wekan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wekan/wekan/downloads","issues_url":"https://api.github.com/repos/wekan/wekan/issues{/number}","pulls_url":"https://api.github.com/repos/wekan/wekan/pulls{/number}","milestones_url":"https://api.github.com/repos/wekan/wekan/milestones{/number}","notifications_url":"https://api.github.com/repos/wekan/wekan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wekan/wekan/labels{/name}","releases_url":"https://api.github.com/repos/wekan/wekan/releases{/id}","created_at":"2014-01-21T01:26:28Z","updated_at":"2015-12-04T04:36:20Z","pushed_at":"2015-12-04T04:11:44Z","git_url":"git://github.com/wekan/wekan.git","ssh_url":"git@github.com:wekan/wekan.git","clone_url":"https://github.com/wekan/wekan.git","svn_url":"https://github.com/wekan/wekan","homepage":"https://wekan.io","size":2517,"stargazers_count":5189,"watchers_count":5189,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":580,"mirror_url":null,"open_issues_count":114,"forks":580,"open_issues":114,"watchers":5189,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/wekan/wekan/pulls/422"},"html":{"href":"https://github.com/wekan/wekan/pull/422"},"issue":{"href":"https://api.github.com/repos/wekan/wekan/issues/422"},"comments":{"href":"https://api.github.com/repos/wekan/wekan/issues/422/comments"},"review_comments":{"href":"https://api.github.com/repos/wekan/wekan/pulls/422/comments"},"review_comment":{"href":"https://api.github.com/repos/wekan/wekan/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wekan/wekan/pulls/422/commits"},"statuses":{"href":"https://api.github.com/repos/wekan/wekan/statuses/e88eb7504ea173a097f0697d7b04ea4a67d674c0"}}}}