{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/29827646","id":29827646,"diff_hunk":"@@ -0,0 +1,231 @@\n+<?php\n+\n+/*\n+ * This file is part of the Sylius package.\n+ *\n+ * (c) Paweł Jędrzejewski\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Sylius\\Bundle\\UserBundle\\Controller;\n+\n+use Sylius\\Bundle\\ResourceBundle\\Controller\\ResourceController;\n+use Sylius\\Bundle\\UserBundle\\Form\\Model\\ChangePassword;\n+use Sylius\\Bundle\\UserBundle\\Form\\Model\\PasswordReset;\n+use Sylius\\Bundle\\UserBundle\\Form\\Type\\UserChangePasswordType;\n+use Sylius\\Bundle\\UserBundle\\Form\\Type\\UserRequestPasswordResetType;\n+use Sylius\\Bundle\\UserBundle\\Form\\Type\\UserResetPasswordType;\n+use Sylius\\Bundle\\UserBundle\\UserEvents;\n+use Sylius\\Component\\User\\Security\\TokenProviderInterface;\n+use Symfony\\Component\\EventDispatcher\\GenericEvent;\n+use Symfony\\Component\\HttpFoundation\\RedirectResponse;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException;\n+\n+/**\n+ * @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>\n+ */\n+class UserController extends ResourceController\n+{\n+    public function changePasswordAction(Request $request)\n+    {\n+        $user = $this->getUser();\n+        $changePassword = new ChangePassword();\n+        $form = $this->createResourceForm(new UserChangePasswordType(), $changePassword);\n+\n+        if (in_array($request->getMethod(), array('POST', 'PUT', 'PATCH')) && $form->submit($request, !$request->isMethod('PATCH'))->isValid()) {\n+            $encoderFactory = $this->get('security.encoder_factory');\n+\n+            $encoder = $encoderFactory->getEncoder($user);\n+            $validPassword = $encoder->isPasswordValid(\n+                $user->getPassword(),\n+                $changePassword->getCurrentPassword(),\n+                $user->getSalt()\n+            );\n+\n+            if ($validPassword) {\n+                $user->setPlainPassword($changePassword->getNewPassword());\n+\n+                $dispatcher = $this->get('event_dispatcher');\n+                $event = new GenericEvent($user);\n+                $dispatcher->dispatch(UserEvents::PASSWORD_RESET_SUCCESS, $event);\n+\n+                $this->domainManager->update($user);\n+\n+                if ($this->config->isApiRequest()) {\n+                    return $this->handleView($this->view($user, 204));\n+                }\n+\n+                $url = $this->generateUrl('sylius_account_homepage');\n+\n+                $this->addFlash('success', 'sylius.account.password.change_success');\n+\n+                return new RedirectResponse($url);\n+            }\n+\n+            $this->addFlash('error', 'sylius.account.password.invalid');\n+        }\n+\n+        if ($this->config->isApiRequest()) {\n+            return $this->handleView($this->view($form, 400));\n+        }\n+\n+        return $this->render(\n+            'SyliusWebBundle:Frontend/Account:changePassword.html.twig',\n+            array(\n+                'form'  => $form->createView(),\n+            )\n+        );\n+    }\n+\n+    public function requestPasswordResetTokenAction(Request $request)\n+    {\n+        $generator = $this->get('sylius.user.token_provider');\n+\n+        return $this->prepereResetPasswordRequest($request, $generator, UserEvents::REQUEST_RESET_PASSWORD_TOKEN);\n+    }\n+\n+    public function requestPasswordResetPinAction(Request $request)\n+    {\n+        $generator = $this->get('sylius.user.pin_provider');\n+\n+        return $this->prepereResetPasswordRequest($request, $generator, UserEvents::REQUEST_RESET_PASSWORD_PIN);\n+    }\n+\n+    public function resetPasswordAction(Request $request)\n+    {\n+        $user = $this->getRepository()->findOneBy(array('confirmationToken' => $request->get('token')));\n+\n+        if (null === $user) {\n+            throw new NotFoundHttpException('This website does not exist');","path":"src/Sylius/Bundle/UserBundle/Controller/UserController.php","position":102,"original_position":102,"commit_id":"46071fb9a566dc6b82929d3effb950de2db5dde7","original_commit_id":"46071fb9a566dc6b82929d3effb950de2db5dde7","user":{"login":"peteward","id":7068515,"avatar_url":"https://avatars.githubusercontent.com/u/7068515?v=3","gravatar_id":"","url":"https://api.github.com/users/peteward","html_url":"https://github.com/peteward","followers_url":"https://api.github.com/users/peteward/followers","following_url":"https://api.github.com/users/peteward/following{/other_user}","gists_url":"https://api.github.com/users/peteward/gists{/gist_id}","starred_url":"https://api.github.com/users/peteward/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peteward/subscriptions","organizations_url":"https://api.github.com/users/peteward/orgs","repos_url":"https://api.github.com/users/peteward/repos","events_url":"https://api.github.com/users/peteward/events{/privacy}","received_events_url":"https://api.github.com/users/peteward/received_events","type":"User","site_admin":false},"body":"This website does not exist? really?","created_at":"2015-05-07T06:32:25Z","updated_at":"2015-05-07T06:32:25Z","html_url":"https://github.com/Sylius/Sylius/pull/2717#discussion_r29827646","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2717","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/29827646"},"html":{"href":"https://github.com/Sylius/Sylius/pull/2717#discussion_r29827646"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2717"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/2717","id":34802739,"html_url":"https://github.com/Sylius/Sylius/pull/2717","diff_url":"https://github.com/Sylius/Sylius/pull/2717.diff","patch_url":"https://github.com/Sylius/Sylius/pull/2717.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/2717","number":2717,"state":"open","locked":false,"title":"[WIP] SyliusUserBundle with user and customer separation","user":{"login":"michalmarcinkowski","id":7572437,"avatar_url":"https://avatars.githubusercontent.com/u/7572437?v=3","gravatar_id":"","url":"https://api.github.com/users/michalmarcinkowski","html_url":"https://github.com/michalmarcinkowski","followers_url":"https://api.github.com/users/michalmarcinkowski/followers","following_url":"https://api.github.com/users/michalmarcinkowski/following{/other_user}","gists_url":"https://api.github.com/users/michalmarcinkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmarcinkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmarcinkowski/subscriptions","organizations_url":"https://api.github.com/users/michalmarcinkowski/orgs","repos_url":"https://api.github.com/users/michalmarcinkowski/repos","events_url":"https://api.github.com/users/michalmarcinkowski/events{/privacy}","received_events_url":"https://api.github.com/users/michalmarcinkowski/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | yes\r\n| Deprecations? | yes\r\n| Fixed tickets |\r\n| License       | MIT\r\n| Doc PR        | WIP\r\n\r\nHey folks!\r\n\r\nWith this PR, Sylius has a brand new UserBundle which replaces FOSUserBundle. Aside from fact that FOSUserBundle does not fit Sylius's conventions, the main reason of this new bundle is customer and user separation, what couldn't be done with FOSUserBundle. There are many usecases where this split is required or at least helpful. IMO the best would be to have CustomerBundle and UserBundle separated (so you can have ability take only one bundle for your project outside Sylius), shouldn't be a problem, but will require more work. This is an initial version and there is a lot to improve. Let's see how does it look right now:\r\n\r\n## Customer\r\n\r\n* Entity which represents customer in the system\r\n* Has all personal information (firstname, lastname, email, birthday etc.)\r\n* Customer owns all ecommerce relations like orders, addresses etc.\r\n* Customer can't log in (doesn't have password or security roles) until he registers (see below **User**)\r\n* Customer can represent B2B client or guest user\r\n* Customer can be assigned to contact requests, newsletter and contests without need to register\r\n\r\n## User\r\n\r\n* Entity which represents registered customer in the system\r\n* User's solely responsibility is to contain only data required for security or account management (credentials, account disabled, security roles etc.)\r\n* User adds ability to log in and manage account and personal information for customer\r\n* User knows nothing about ecommerce parts\r\n\r\n### UI/UX topics I wanted to rise up and get your feedback\r\n\r\n1. During guest checkout addresses should not be assigned to customer (sensitive information)\r\n2. After register, user is connected with customer based on email address which is unique\r\n3. Registered user is able to display orders which were placed earlier by guest checkout with his email address\r\n4. When user wants to do guest checkout with already registered email. Validation does not pass and user is asked to login.\r\n\r\n### TODO\r\n- [ ] Polish and improve code\r\n- [ ] Write more specs and Behat scenarios\r\n- [ ] Rework backend management of users/customers\r\n- [ ] Update last login property\r\n- [ ] Create user factory which creates new user together with injected new customer (if your service will create new users, only one factory will be required to be injected) - waiting for #2255","created_at":"2015-05-06T09:57:41Z","updated_at":"2015-05-07T06:32:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9501da65fadfc2b239c7bd34402024c44a1db2fc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2717/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2717/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/2717/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/46071fb9a566dc6b82929d3effb950de2db5dde7","head":{"label":"michalmarcinkowski:customer-user-split","ref":"customer-user-split","sha":"46071fb9a566dc6b82929d3effb950de2db5dde7","user":{"login":"michalmarcinkowski","id":7572437,"avatar_url":"https://avatars.githubusercontent.com/u/7572437?v=3","gravatar_id":"","url":"https://api.github.com/users/michalmarcinkowski","html_url":"https://github.com/michalmarcinkowski","followers_url":"https://api.github.com/users/michalmarcinkowski/followers","following_url":"https://api.github.com/users/michalmarcinkowski/following{/other_user}","gists_url":"https://api.github.com/users/michalmarcinkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmarcinkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmarcinkowski/subscriptions","organizations_url":"https://api.github.com/users/michalmarcinkowski/orgs","repos_url":"https://api.github.com/users/michalmarcinkowski/repos","events_url":"https://api.github.com/users/michalmarcinkowski/events{/privacy}","received_events_url":"https://api.github.com/users/michalmarcinkowski/received_events","type":"User","site_admin":false},"repo":{"id":24368225,"name":"Sylius","full_name":"michalmarcinkowski/Sylius","owner":{"login":"michalmarcinkowski","id":7572437,"avatar_url":"https://avatars.githubusercontent.com/u/7572437?v=3","gravatar_id":"","url":"https://api.github.com/users/michalmarcinkowski","html_url":"https://github.com/michalmarcinkowski","followers_url":"https://api.github.com/users/michalmarcinkowski/followers","following_url":"https://api.github.com/users/michalmarcinkowski/following{/other_user}","gists_url":"https://api.github.com/users/michalmarcinkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/michalmarcinkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michalmarcinkowski/subscriptions","organizations_url":"https://api.github.com/users/michalmarcinkowski/orgs","repos_url":"https://api.github.com/users/michalmarcinkowski/repos","events_url":"https://api.github.com/users/michalmarcinkowski/events{/privacy}","received_events_url":"https://api.github.com/users/michalmarcinkowski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michalmarcinkowski/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/michalmarcinkowski/Sylius","forks_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/forks","keys_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/teams","hooks_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/hooks","issue_events_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/events","assignees_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/tags","blobs_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/languages","stargazers_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/stargazers","contributors_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/contributors","subscribers_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/subscribers","subscription_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/subscription","commits_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/merges","archive_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/downloads","issues_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/michalmarcinkowski/Sylius/releases{/id}","created_at":"2014-09-23T11:16:27Z","updated_at":"2015-01-12T08:26:15Z","pushed_at":"2015-05-06T14:10:15Z","git_url":"git://github.com/michalmarcinkowski/Sylius.git","ssh_url":"git@github.com:michalmarcinkowski/Sylius.git","clone_url":"https://github.com/michalmarcinkowski/Sylius.git","svn_url":"https://github.com/michalmarcinkowski/Sylius","homepage":"Sylius.org","size":17109,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"Sylius:master","ref":"master","sha":"8e37eb1b61e34d4dc0d48b7fcbd5a09d61b6012e","user":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"repo":{"id":2717549,"name":"Sylius","full_name":"Sylius/Sylius","owner":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sylius/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":false,"url":"https://api.github.com/repos/Sylius/Sylius","forks_url":"https://api.github.com/repos/Sylius/Sylius/forks","keys_url":"https://api.github.com/repos/Sylius/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sylius/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sylius/Sylius/teams","hooks_url":"https://api.github.com/repos/Sylius/Sylius/hooks","issue_events_url":"https://api.github.com/repos/Sylius/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/Sylius/Sylius/events","assignees_url":"https://api.github.com/repos/Sylius/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/Sylius/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/Sylius/Sylius/tags","blobs_url":"https://api.github.com/repos/Sylius/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sylius/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sylius/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sylius/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/Sylius/Sylius/languages","stargazers_url":"https://api.github.com/repos/Sylius/Sylius/stargazers","contributors_url":"https://api.github.com/repos/Sylius/Sylius/contributors","subscribers_url":"https://api.github.com/repos/Sylius/Sylius/subscribers","subscription_url":"https://api.github.com/repos/Sylius/Sylius/subscription","commits_url":"https://api.github.com/repos/Sylius/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sylius/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sylius/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sylius/Sylius/issues/comments{/number}","contents_url":"https://api.github.com/repos/Sylius/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/Sylius/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sylius/Sylius/merges","archive_url":"https://api.github.com/repos/Sylius/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sylius/Sylius/downloads","issues_url":"https://api.github.com/repos/Sylius/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/Sylius/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/Sylius/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/Sylius/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sylius/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/Sylius/Sylius/releases{/id}","created_at":"2011-11-05T22:05:52Z","updated_at":"2015-05-06T21:56:55Z","pushed_at":"2015-05-07T00:42:56Z","git_url":"git://github.com/Sylius/Sylius.git","ssh_url":"git@github.com:Sylius/Sylius.git","clone_url":"https://github.com/Sylius/Sylius.git","svn_url":"https://github.com/Sylius/Sylius","homepage":"Sylius.org","size":46918,"stargazers_count":1763,"watchers_count":1763,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":603,"mirror_url":null,"open_issues_count":417,"forks":603,"open_issues":417,"watchers":1763,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2717"},"html":{"href":"https://github.com/Sylius/Sylius/pull/2717"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/2717"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/2717/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2717/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2717/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/46071fb9a566dc6b82929d3effb950de2db5dde7"}}}}