{"action":"created","comment":{"url":"https://api.github.com/repos/nodes-php/api/pulls/comments/65537416","id":65537416,"diff_hunk":"@@ -0,0 +1,206 @@\n+<?php\n+namespace Nodes\\Api\\Auth\\EmailVerification;\n+\n+use Carbon\\Carbon;\n+use Illuminate\\Database\\Eloquent\\Model as IlluminateModel;\n+use Illuminate\\Support\\Facades\\Mail;\n+use Nodes\\Api\\Auth\\Exceptions\\ResetPasswordNoUserException;\n+use Nodes\\Database\\Eloquent\\Repository as NodesRepository;\n+use Nodes\\Api\\Auth\\Exceptions\\MissingUserModelException;\n+\n+\n+/**\n+ * Class ResetPasswordRepository\n+ *\n+ * @package Nodes\\Api\\Auth\\ResetPassword\n+ */\n+class EmailVerificationRepository extends NodesRepository\n+{\n+    /**\n+     * API auth model\n+     *\n+     * @var \\Illuminate\\Database\\Eloquent\\Model\n+     */\n+    protected $authModel;\n+\n+    /**\n+     * Constructor\n+     *\n+     * @author Paulius Navickas <pana@nodes.dk>\n+     *\n+     * @access public\n+     * @param  \\Nodes\\Api\\Auth\\EmailVerification\\EmailVerificationModel $model\n+     * @throws \\Nodes\\Api\\Auth\\Exceptions\\MissingUserModelException\n+     */\n+    public function __construct(EmailVerificationModel $model)\n+    {\n+        $this->setupRepository($model);\n+\n+        // Retrieve namespace of API auth model\n+        $userModel = config('nodes.api.auth.model', null);\n+        if (empty($userModel)) {\n+            throw new MissingUserModelException('No API auth model has been specified');\n+        }\n+\n+        // Instantiate auth model\n+        $this->authModel = app($userModel);\n+    }\n+\n+    /**\n+     * Retrieve by token\n+     *\n+     * @author Paulius Navickas <pana@nodes.dk>\n+     *\n+     * @access public\n+     * @param  string $token\n+     * @return \\Nodes\\Api\\Auth\\EmailVerification\\Model\n+     */\n+    public function getByToken($token)\n+    {\n+        dd($token);\n+        return $this->where('token', '=', $token)\n+            ->first();\n+    }\n+\n+    /**\n+     * Retrieve by unexpired token\n+     *\n+     * @author Paulius Navickas <pana@nodes.dk>\n+     *\n+     * @access public\n+     * @param  string $token\n+     * @return \\Nodes\\Api\\Auth\\ResetPassword\\ResetPasswordModel\n+     */\n+    public function getByUnexpiredToken($token)\n+    {\n+        return $this->where('token', '=', $token)\n+            ->where('expire_at', '>', Carbon::now()->format('Y-m-d H:i:s'))\n+            ->first();\n+    }\n+\n+    /**\n+     * Generate and send a email with link instructions\n+     *\n+     * @author Paulius Navickas <pana@nodes.dk>\n+     *\n+     * @access public\n+     * @param  array $conditions WHERE conditions to locate user. Format: ['column' => 'value']\n+     * @return boolean\n+     * @throws \\Nodes\\Api\\Auth\\Exceptions\\ResetPasswordNoUserException\n+     */\n+    public function sendVerificationEmail($user)\n+    {\n+        if (empty($user)) {\n+            throw new ResetPasswordNoUserException('Could not find any user with those credentials');\n+        }\n+\n+        // Generate email verification token\n+        $token = $this->generateEmailVerificationToken($user);\n+\n+        // Generate email verification domain\n+        $domain = env('NODES_ENV', false) ? sprintf('https://%s.%s', env('APP_NAME'), env('APP_DOMAIN')) : config('app.url');\n+\n+        // Send e-mail with instructions on how to reset password\n+        $status = (bool) Mail::send([\n+            'html' => config('nodes.api.email-verification.views.html', 'nodes.api::email-verification.emails.html'),\n+            'text' => config('nodes.api.email-verification.views.text', 'nodes.api::email-verification.emails.text')\n+        ], [\n+            'user' => $user,\n+            'domain' => $domain,\n+            'email' => $user->email,\n+            'token' => $token,","path":"src/Auth/EmailVerification/EmailVerificationRepository.php","position":111,"original_position":111,"commit_id":"611b3fc12290fea8a1bd8f5531cd37deef8f0d26","original_commit_id":"611b3fc12290fea8a1bd8f5531cd37deef8f0d26","user":{"login":"rugaard","id":179868,"avatar_url":"https://avatars.githubusercontent.com/u/179868?v=3","gravatar_id":"","url":"https://api.github.com/users/rugaard","html_url":"https://github.com/rugaard","followers_url":"https://api.github.com/users/rugaard/followers","following_url":"https://api.github.com/users/rugaard/following{/other_user}","gists_url":"https://api.github.com/users/rugaard/gists{/gist_id}","starred_url":"https://api.github.com/users/rugaard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rugaard/subscriptions","organizations_url":"https://api.github.com/users/rugaard/orgs","repos_url":"https://api.github.com/users/rugaard/repos","events_url":"https://api.github.com/users/rugaard/events{/privacy}","received_events_url":"https://api.github.com/users/rugaard/received_events","type":"User","site_admin":false},"body":"Using incorrect field since you've renamed the field from `token` to `verification`","created_at":"2016-06-02T13:21:24Z","updated_at":"2016-06-02T13:21:24Z","html_url":"https://github.com/nodes-php/api/pull/35#discussion_r65537416","pull_request_url":"https://api.github.com/repos/nodes-php/api/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/nodes-php/api/pulls/comments/65537416"},"html":{"href":"https://github.com/nodes-php/api/pull/35#discussion_r65537416"},"pull_request":{"href":"https://api.github.com/repos/nodes-php/api/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/nodes-php/api/pulls/35","id":72341138,"html_url":"https://github.com/nodes-php/api/pull/35","diff_url":"https://github.com/nodes-php/api/pull/35.diff","patch_url":"https://github.com/nodes-php/api/pull/35.patch","issue_url":"https://api.github.com/repos/nodes-php/api/issues/35","number":35,"state":"open","locked":false,"title":"Feature/email verification","user":{"login":"Zeneo","id":5598307,"avatar_url":"https://avatars.githubusercontent.com/u/5598307?v=3","gravatar_id":"","url":"https://api.github.com/users/Zeneo","html_url":"https://github.com/Zeneo","followers_url":"https://api.github.com/users/Zeneo/followers","following_url":"https://api.github.com/users/Zeneo/following{/other_user}","gists_url":"https://api.github.com/users/Zeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zeneo/subscriptions","organizations_url":"https://api.github.com/users/Zeneo/orgs","repos_url":"https://api.github.com/users/Zeneo/repos","events_url":"https://api.github.com/users/Zeneo/events{/privacy}","received_events_url":"https://api.github.com/users/Zeneo/received_events","type":"User","site_admin":false},"body":"Email verification module. \r\n\r\nOn user storing:\r\n$this->emailVerificationRepository->sendVerificationEmail($user);\r\n\r\nAnd its done. User gets email with active link.\r\nCommand line is missing for installation of module","created_at":"2016-06-02T12:55:46Z","updated_at":"2016-06-02T13:21:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3418cabef2a4b529cee6d2c9efd1dafcd99db96e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodes-php/api/pulls/35/commits","review_comments_url":"https://api.github.com/repos/nodes-php/api/pulls/35/comments","review_comment_url":"https://api.github.com/repos/nodes-php/api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodes-php/api/issues/35/comments","statuses_url":"https://api.github.com/repos/nodes-php/api/statuses/611b3fc12290fea8a1bd8f5531cd37deef8f0d26","head":{"label":"nodes-php:feature/email-verification","ref":"feature/email-verification","sha":"611b3fc12290fea8a1bd8f5531cd37deef8f0d26","user":{"login":"nodes-php","id":15651590,"avatar_url":"https://avatars.githubusercontent.com/u/15651590?v=3","gravatar_id":"","url":"https://api.github.com/users/nodes-php","html_url":"https://github.com/nodes-php","followers_url":"https://api.github.com/users/nodes-php/followers","following_url":"https://api.github.com/users/nodes-php/following{/other_user}","gists_url":"https://api.github.com/users/nodes-php/gists{/gist_id}","starred_url":"https://api.github.com/users/nodes-php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodes-php/subscriptions","organizations_url":"https://api.github.com/users/nodes-php/orgs","repos_url":"https://api.github.com/users/nodes-php/repos","events_url":"https://api.github.com/users/nodes-php/events{/privacy}","received_events_url":"https://api.github.com/users/nodes-php/received_events","type":"Organization","site_admin":false},"repo":{"id":49190735,"name":"api","full_name":"nodes-php/api","owner":{"login":"nodes-php","id":15651590,"avatar_url":"https://avatars.githubusercontent.com/u/15651590?v=3","gravatar_id":"","url":"https://api.github.com/users/nodes-php","html_url":"https://github.com/nodes-php","followers_url":"https://api.github.com/users/nodes-php/followers","following_url":"https://api.github.com/users/nodes-php/following{/other_user}","gists_url":"https://api.github.com/users/nodes-php/gists{/gist_id}","starred_url":"https://api.github.com/users/nodes-php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodes-php/subscriptions","organizations_url":"https://api.github.com/users/nodes-php/orgs","repos_url":"https://api.github.com/users/nodes-php/repos","events_url":"https://api.github.com/users/nodes-php/events{/privacy}","received_events_url":"https://api.github.com/users/nodes-php/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodes-php/api","description":"Nodes wrapper for Dingo API","fork":false,"url":"https://api.github.com/repos/nodes-php/api","forks_url":"https://api.github.com/repos/nodes-php/api/forks","keys_url":"https://api.github.com/repos/nodes-php/api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodes-php/api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodes-php/api/teams","hooks_url":"https://api.github.com/repos/nodes-php/api/hooks","issue_events_url":"https://api.github.com/repos/nodes-php/api/issues/events{/number}","events_url":"https://api.github.com/repos/nodes-php/api/events","assignees_url":"https://api.github.com/repos/nodes-php/api/assignees{/user}","branches_url":"https://api.github.com/repos/nodes-php/api/branches{/branch}","tags_url":"https://api.github.com/repos/nodes-php/api/tags","blobs_url":"https://api.github.com/repos/nodes-php/api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodes-php/api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodes-php/api/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodes-php/api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodes-php/api/statuses/{sha}","languages_url":"https://api.github.com/repos/nodes-php/api/languages","stargazers_url":"https://api.github.com/repos/nodes-php/api/stargazers","contributors_url":"https://api.github.com/repos/nodes-php/api/contributors","subscribers_url":"https://api.github.com/repos/nodes-php/api/subscribers","subscription_url":"https://api.github.com/repos/nodes-php/api/subscription","commits_url":"https://api.github.com/repos/nodes-php/api/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodes-php/api/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodes-php/api/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodes-php/api/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodes-php/api/contents/{+path}","compare_url":"https://api.github.com/repos/nodes-php/api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodes-php/api/merges","archive_url":"https://api.github.com/repos/nodes-php/api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodes-php/api/downloads","issues_url":"https://api.github.com/repos/nodes-php/api/issues{/number}","pulls_url":"https://api.github.com/repos/nodes-php/api/pulls{/number}","milestones_url":"https://api.github.com/repos/nodes-php/api/milestones{/number}","notifications_url":"https://api.github.com/repos/nodes-php/api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodes-php/api/labels{/name}","releases_url":"https://api.github.com/repos/nodes-php/api/releases{/id}","deployments_url":"https://api.github.com/repos/nodes-php/api/deployments","created_at":"2016-01-07T08:08:10Z","updated_at":"2016-01-15T16:23:32Z","pushed_at":"2016-06-02T12:55:46Z","git_url":"git://github.com/nodes-php/api.git","ssh_url":"git@github.com:nodes-php/api.git","clone_url":"https://github.com/nodes-php/api.git","svn_url":"https://github.com/nodes-php/api","homepage":"http://nodesagency.com","size":132,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"nodes-php:master","ref":"master","sha":"17cd823c4b004a08eecf3e425836d1452f3b3343","user":{"login":"nodes-php","id":15651590,"avatar_url":"https://avatars.githubusercontent.com/u/15651590?v=3","gravatar_id":"","url":"https://api.github.com/users/nodes-php","html_url":"https://github.com/nodes-php","followers_url":"https://api.github.com/users/nodes-php/followers","following_url":"https://api.github.com/users/nodes-php/following{/other_user}","gists_url":"https://api.github.com/users/nodes-php/gists{/gist_id}","starred_url":"https://api.github.com/users/nodes-php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodes-php/subscriptions","organizations_url":"https://api.github.com/users/nodes-php/orgs","repos_url":"https://api.github.com/users/nodes-php/repos","events_url":"https://api.github.com/users/nodes-php/events{/privacy}","received_events_url":"https://api.github.com/users/nodes-php/received_events","type":"Organization","site_admin":false},"repo":{"id":49190735,"name":"api","full_name":"nodes-php/api","owner":{"login":"nodes-php","id":15651590,"avatar_url":"https://avatars.githubusercontent.com/u/15651590?v=3","gravatar_id":"","url":"https://api.github.com/users/nodes-php","html_url":"https://github.com/nodes-php","followers_url":"https://api.github.com/users/nodes-php/followers","following_url":"https://api.github.com/users/nodes-php/following{/other_user}","gists_url":"https://api.github.com/users/nodes-php/gists{/gist_id}","starred_url":"https://api.github.com/users/nodes-php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodes-php/subscriptions","organizations_url":"https://api.github.com/users/nodes-php/orgs","repos_url":"https://api.github.com/users/nodes-php/repos","events_url":"https://api.github.com/users/nodes-php/events{/privacy}","received_events_url":"https://api.github.com/users/nodes-php/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodes-php/api","description":"Nodes wrapper for Dingo API","fork":false,"url":"https://api.github.com/repos/nodes-php/api","forks_url":"https://api.github.com/repos/nodes-php/api/forks","keys_url":"https://api.github.com/repos/nodes-php/api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodes-php/api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodes-php/api/teams","hooks_url":"https://api.github.com/repos/nodes-php/api/hooks","issue_events_url":"https://api.github.com/repos/nodes-php/api/issues/events{/number}","events_url":"https://api.github.com/repos/nodes-php/api/events","assignees_url":"https://api.github.com/repos/nodes-php/api/assignees{/user}","branches_url":"https://api.github.com/repos/nodes-php/api/branches{/branch}","tags_url":"https://api.github.com/repos/nodes-php/api/tags","blobs_url":"https://api.github.com/repos/nodes-php/api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodes-php/api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodes-php/api/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodes-php/api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodes-php/api/statuses/{sha}","languages_url":"https://api.github.com/repos/nodes-php/api/languages","stargazers_url":"https://api.github.com/repos/nodes-php/api/stargazers","contributors_url":"https://api.github.com/repos/nodes-php/api/contributors","subscribers_url":"https://api.github.com/repos/nodes-php/api/subscribers","subscription_url":"https://api.github.com/repos/nodes-php/api/subscription","commits_url":"https://api.github.com/repos/nodes-php/api/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodes-php/api/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodes-php/api/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodes-php/api/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodes-php/api/contents/{+path}","compare_url":"https://api.github.com/repos/nodes-php/api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodes-php/api/merges","archive_url":"https://api.github.com/repos/nodes-php/api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodes-php/api/downloads","issues_url":"https://api.github.com/repos/nodes-php/api/issues{/number}","pulls_url":"https://api.github.com/repos/nodes-php/api/pulls{/number}","milestones_url":"https://api.github.com/repos/nodes-php/api/milestones{/number}","notifications_url":"https://api.github.com/repos/nodes-php/api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodes-php/api/labels{/name}","releases_url":"https://api.github.com/repos/nodes-php/api/releases{/id}","deployments_url":"https://api.github.com/repos/nodes-php/api/deployments","created_at":"2016-01-07T08:08:10Z","updated_at":"2016-01-15T16:23:32Z","pushed_at":"2016-06-02T12:55:46Z","git_url":"git://github.com/nodes-php/api.git","ssh_url":"git@github.com:nodes-php/api.git","clone_url":"https://github.com/nodes-php/api.git","svn_url":"https://github.com/nodes-php/api","homepage":"http://nodesagency.com","size":132,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodes-php/api/pulls/35"},"html":{"href":"https://github.com/nodes-php/api/pull/35"},"issue":{"href":"https://api.github.com/repos/nodes-php/api/issues/35"},"comments":{"href":"https://api.github.com/repos/nodes-php/api/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/nodes-php/api/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/nodes-php/api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodes-php/api/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/nodes-php/api/statuses/611b3fc12290fea8a1bd8f5531cd37deef8f0d26"}}}}
{"actor":{"display_login":"rugaard"}}