{"action":"created","comment":{"url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/comments/44421032","id":44421032,"diff_hunk":"@@ -53,3 +60,50 @@ def jsontify_function(*args, **kwargs):\n         response.content_type = 'application/json'\n         return dumps(result)\n     return jsontify_function\n+\n+\n+def generate_confirmation_token(config, email):\n+    \"\"\"generate confirmation token using user's email via itsdangerous\"\"\"\n+    serializer = URLSafeTimedSerializer(config['site.secret_key'])\n+    return serializer.dumps(email, salt=config['site.token_salt'])\n+\n+\n+def validate_token(config, token, expire_time=3600):\n+    \"\"\"from token and expire_time to confirm user's email\"\"\"\n+    serializer = URLSafeTimedSerializer(config['site.secret_key'])\n+    try:\n+        confirmed_email = serializer.loads(token, max_age=expire_time, salt=config['site.token_salt'])\n+    except Exception:\n+        return False\n+    return confirmed_email\n+\n+\n+sender = 'noreply.daimaduan@gmail.com'","path":"daimaduan/utils.py","position":48,"original_position":48,"commit_id":"4fc143d2cf3d753a6761924d93422e91fb78631d","original_commit_id":"4fc143d2cf3d753a6761924d93422e91fb78631d","user":{"login":"david-xie","id":100747,"avatar_url":"https://avatars.githubusercontent.com/u/100747?v=3","gravatar_id":"","url":"https://api.github.com/users/david-xie","html_url":"https://github.com/david-xie","followers_url":"https://api.github.com/users/david-xie/followers","following_url":"https://api.github.com/users/david-xie/following{/other_user}","gists_url":"https://api.github.com/users/david-xie/gists{/gist_id}","starred_url":"https://api.github.com/users/david-xie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-xie/subscriptions","organizations_url":"https://api.github.com/users/david-xie/orgs","repos_url":"https://api.github.com/users/david-xie/repos","events_url":"https://api.github.com/users/david-xie/events{/privacy}","received_events_url":"https://api.github.com/users/david-xie/received_events","type":"User","site_admin":false},"body":"常量最好大写","created_at":"2015-11-10T15:41:30Z","updated_at":"2015-11-10T15:41:30Z","html_url":"https://github.com/DoubleCiti/daimaduan.com/pull/44#discussion_r44421032","pull_request_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/comments/44421032"},"html":{"href":"https://github.com/DoubleCiti/daimaduan.com/pull/44#discussion_r44421032"},"pull_request":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44","id":49514018,"html_url":"https://github.com/DoubleCiti/daimaduan.com/pull/44","diff_url":"https://github.com/DoubleCiti/daimaduan.com/pull/44.diff","patch_url":"https://github.com/DoubleCiti/daimaduan.com/pull/44.patch","issue_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues/44","number":44,"state":"open","locked":false,"title":"[#14] basic function of verify email","user":{"login":"liul85","id":1312723,"avatar_url":"https://avatars.githubusercontent.com/u/1312723?v=3","gravatar_id":"","url":"https://api.github.com/users/liul85","html_url":"https://github.com/liul85","followers_url":"https://api.github.com/users/liul85/followers","following_url":"https://api.github.com/users/liul85/following{/other_user}","gists_url":"https://api.github.com/users/liul85/gists{/gist_id}","starred_url":"https://api.github.com/users/liul85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liul85/subscriptions","organizations_url":"https://api.github.com/users/liul85/orgs","repos_url":"https://api.github.com/users/liul85/repos","events_url":"https://api.github.com/users/liul85/events{/privacy}","received_events_url":"https://api.github.com/users/liul85/received_events","type":"User","site_admin":false},"body":"修改地方：\r\n1. config中加了发件邮箱的username和password配置。\r\n2. 增加了confirm_token.py，用来生成临时token和从提交过来的token验证。\r\n3. 增加了mail.py，用Mailthon来发送邮件。\r\n4. model中增加了`is_email_confirmed`和`email_confirmed_on`field\r\n5. 在注册成功后发送邮件。\r\n6. 在验证链接中验证提交的token，token是根据密钥+email计算得来，验证时候是根据token和设置的过期时间来计算得到用户email，再根据email查询用户。\r\n\r\n先review，我再修改。\r\n\r\n后面还要做的：\r\n1. 用户没激活之前不能发布daimaduan，应该可以查看其他公开的。\r\n2. 注册成功发邮件那部分应该做成异步的。\r\n3. 注册成功应该跳转到一个页面显示“注册成功，已经发emial等确认”等这样的一个提示页面。\r\n4. 如果用户没收到email，还可以重新发送email功能。","created_at":"2015-11-03T02:40:27Z","updated_at":"2015-11-10T15:41:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a98af36d4b53fade5a1e18a4625c119cff630d78","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44/commits","review_comments_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44/comments","review_comment_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues/44/comments","statuses_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/statuses/4fc143d2cf3d753a6761924d93422e91fb78631d","head":{"label":"liul85:email_confirmation","ref":"email_confirmation","sha":"4fc143d2cf3d753a6761924d93422e91fb78631d","user":{"login":"liul85","id":1312723,"avatar_url":"https://avatars.githubusercontent.com/u/1312723?v=3","gravatar_id":"","url":"https://api.github.com/users/liul85","html_url":"https://github.com/liul85","followers_url":"https://api.github.com/users/liul85/followers","following_url":"https://api.github.com/users/liul85/following{/other_user}","gists_url":"https://api.github.com/users/liul85/gists{/gist_id}","starred_url":"https://api.github.com/users/liul85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liul85/subscriptions","organizations_url":"https://api.github.com/users/liul85/orgs","repos_url":"https://api.github.com/users/liul85/repos","events_url":"https://api.github.com/users/liul85/events{/privacy}","received_events_url":"https://api.github.com/users/liul85/received_events","type":"User","site_admin":false},"repo":{"id":41522508,"name":"daimaduan.com","full_name":"liul85/daimaduan.com","owner":{"login":"liul85","id":1312723,"avatar_url":"https://avatars.githubusercontent.com/u/1312723?v=3","gravatar_id":"","url":"https://api.github.com/users/liul85","html_url":"https://github.com/liul85","followers_url":"https://api.github.com/users/liul85/followers","following_url":"https://api.github.com/users/liul85/following{/other_user}","gists_url":"https://api.github.com/users/liul85/gists{/gist_id}","starred_url":"https://api.github.com/users/liul85/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liul85/subscriptions","organizations_url":"https://api.github.com/users/liul85/orgs","repos_url":"https://api.github.com/users/liul85/repos","events_url":"https://api.github.com/users/liul85/events{/privacy}","received_events_url":"https://api.github.com/users/liul85/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liul85/daimaduan.com","description":"source code of daimaduan.com","fork":true,"url":"https://api.github.com/repos/liul85/daimaduan.com","forks_url":"https://api.github.com/repos/liul85/daimaduan.com/forks","keys_url":"https://api.github.com/repos/liul85/daimaduan.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liul85/daimaduan.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liul85/daimaduan.com/teams","hooks_url":"https://api.github.com/repos/liul85/daimaduan.com/hooks","issue_events_url":"https://api.github.com/repos/liul85/daimaduan.com/issues/events{/number}","events_url":"https://api.github.com/repos/liul85/daimaduan.com/events","assignees_url":"https://api.github.com/repos/liul85/daimaduan.com/assignees{/user}","branches_url":"https://api.github.com/repos/liul85/daimaduan.com/branches{/branch}","tags_url":"https://api.github.com/repos/liul85/daimaduan.com/tags","blobs_url":"https://api.github.com/repos/liul85/daimaduan.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liul85/daimaduan.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liul85/daimaduan.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/liul85/daimaduan.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liul85/daimaduan.com/statuses/{sha}","languages_url":"https://api.github.com/repos/liul85/daimaduan.com/languages","stargazers_url":"https://api.github.com/repos/liul85/daimaduan.com/stargazers","contributors_url":"https://api.github.com/repos/liul85/daimaduan.com/contributors","subscribers_url":"https://api.github.com/repos/liul85/daimaduan.com/subscribers","subscription_url":"https://api.github.com/repos/liul85/daimaduan.com/subscription","commits_url":"https://api.github.com/repos/liul85/daimaduan.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/liul85/daimaduan.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/liul85/daimaduan.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/liul85/daimaduan.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/liul85/daimaduan.com/contents/{+path}","compare_url":"https://api.github.com/repos/liul85/daimaduan.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liul85/daimaduan.com/merges","archive_url":"https://api.github.com/repos/liul85/daimaduan.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liul85/daimaduan.com/downloads","issues_url":"https://api.github.com/repos/liul85/daimaduan.com/issues{/number}","pulls_url":"https://api.github.com/repos/liul85/daimaduan.com/pulls{/number}","milestones_url":"https://api.github.com/repos/liul85/daimaduan.com/milestones{/number}","notifications_url":"https://api.github.com/repos/liul85/daimaduan.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liul85/daimaduan.com/labels{/name}","releases_url":"https://api.github.com/repos/liul85/daimaduan.com/releases{/id}","created_at":"2015-08-28T02:31:16Z","updated_at":"2015-11-06T15:25:02Z","pushed_at":"2015-11-09T14:44:08Z","git_url":"git://github.com/liul85/daimaduan.com.git","ssh_url":"git@github.com:liul85/daimaduan.com.git","clone_url":"https://github.com/liul85/daimaduan.com.git","svn_url":"https://github.com/liul85/daimaduan.com","homepage":null,"size":380,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DoubleCiti:master","ref":"master","sha":"4ca78a8bedaffa3edba417226dce9aae9e24d5ce","user":{"login":"DoubleCiti","id":1917327,"avatar_url":"https://avatars.githubusercontent.com/u/1917327?v=3","gravatar_id":"","url":"https://api.github.com/users/DoubleCiti","html_url":"https://github.com/DoubleCiti","followers_url":"https://api.github.com/users/DoubleCiti/followers","following_url":"https://api.github.com/users/DoubleCiti/following{/other_user}","gists_url":"https://api.github.com/users/DoubleCiti/gists{/gist_id}","starred_url":"https://api.github.com/users/DoubleCiti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoubleCiti/subscriptions","organizations_url":"https://api.github.com/users/DoubleCiti/orgs","repos_url":"https://api.github.com/users/DoubleCiti/repos","events_url":"https://api.github.com/users/DoubleCiti/events{/privacy}","received_events_url":"https://api.github.com/users/DoubleCiti/received_events","type":"Organization","site_admin":false},"repo":{"id":41431760,"name":"daimaduan.com","full_name":"DoubleCiti/daimaduan.com","owner":{"login":"DoubleCiti","id":1917327,"avatar_url":"https://avatars.githubusercontent.com/u/1917327?v=3","gravatar_id":"","url":"https://api.github.com/users/DoubleCiti","html_url":"https://github.com/DoubleCiti","followers_url":"https://api.github.com/users/DoubleCiti/followers","following_url":"https://api.github.com/users/DoubleCiti/following{/other_user}","gists_url":"https://api.github.com/users/DoubleCiti/gists{/gist_id}","starred_url":"https://api.github.com/users/DoubleCiti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoubleCiti/subscriptions","organizations_url":"https://api.github.com/users/DoubleCiti/orgs","repos_url":"https://api.github.com/users/DoubleCiti/repos","events_url":"https://api.github.com/users/DoubleCiti/events{/privacy}","received_events_url":"https://api.github.com/users/DoubleCiti/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DoubleCiti/daimaduan.com","description":"source code of daimaduan.com","fork":false,"url":"https://api.github.com/repos/DoubleCiti/daimaduan.com","forks_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/forks","keys_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/teams","hooks_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/hooks","issue_events_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues/events{/number}","events_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/events","assignees_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/assignees{/user}","branches_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/branches{/branch}","tags_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/tags","blobs_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/statuses/{sha}","languages_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/languages","stargazers_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/stargazers","contributors_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/contributors","subscribers_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/subscribers","subscription_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/subscription","commits_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/contents/{+path}","compare_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/merges","archive_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/downloads","issues_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues{/number}","pulls_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls{/number}","milestones_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/milestones{/number}","notifications_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/labels{/name}","releases_url":"https://api.github.com/repos/DoubleCiti/daimaduan.com/releases{/id}","created_at":"2015-08-26T14:54:30Z","updated_at":"2015-11-05T20:32:13Z","pushed_at":"2015-11-09T14:44:09Z","git_url":"git://github.com/DoubleCiti/daimaduan.com.git","ssh_url":"git@github.com:DoubleCiti/daimaduan.com.git","clone_url":"https://github.com/DoubleCiti/daimaduan.com.git","svn_url":"https://github.com/DoubleCiti/daimaduan.com","homepage":null,"size":869,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":13,"forks":2,"open_issues":13,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44"},"html":{"href":"https://github.com/DoubleCiti/daimaduan.com/pull/44"},"issue":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues/44"},"comments":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44/comments"},"review_comment":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/pulls/44/commits"},"statuses":{"href":"https://api.github.com/repos/DoubleCiti/daimaduan.com/statuses/4fc143d2cf3d753a6761924d93422e91fb78631d"}}}}