{"action":"created","comment":{"url":"https://api.github.com/repos/Gradder/OnlineShop/pulls/comments/201263459","pull_request_review_id":135728267,"id":201263459,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTI2MzQ1OQ==","diff_hunk":"@@ -2,45 +2,70 @@\n \n import com.epam.onlineshop.entities.User;\n import com.epam.onlineshop.services.UserService;\n-import org.springframework.beans.factory.annotation.Autowired;\n+import lombok.RequiredArgsConstructor;\n+import org.springframework.context.annotation.PropertySource;\n import org.springframework.web.bind.annotation.ModelAttribute;\n import org.springframework.web.bind.annotation.PostMapping;\n import org.springframework.web.bind.annotation.RestController;\n import org.springframework.web.servlet.ModelAndView;\n \n @RestController\n+@RequiredArgsConstructor\n+@PropertySource(\"classpath:/application.properties\")\n public class UserController {\n-    @Autowired\n-    private UserService userService;\n+\n+    private final UserService userService;\n+\n+    private final static String WRONG_SIGNIN = \"Username or Password is wrong!\";\n+    private final static String WRONG_SIGNUP = \"This username is already exist!\";\n \n     @PostMapping(\"/registration\")\n-    public ModelAndView registerUser() {\n-        ModelAndView modelAndView = new ModelAndView();\n+    public ModelAndView registerUser(ModelAndView modelAndView) {\n         modelAndView.addObject(\"newUser\", new User());\n-        modelAndView.addObject(\" registerErrorMessage\", \"hollou\");\n+\n         modelAndView.setViewName(\"regist\");\n         return modelAndView;\n     }\n \n     @PostMapping(\"/signin\")\n-    public ModelAndView signIn(@ModelAttribute(\"userJSP\") User user) {\n-        ModelAndView modelAndView = new ModelAndView();\n-        modelAndView.setViewName(userService.signInUser(user));\n-        modelAndView.addObject(\"userJSP\", user);\n+    public ModelAndView signIn(@ModelAttribute(\"userJSP\") User user, ModelAndView modelAndView) {\n+        if (userService.isExistsByUsername(user.getUsername())) {\n+            modelAndView.setViewName(getViewName(user));\n+            modelAndView.addObject(\"userJSP\", user);\n+        } else {\n+            modelAndView.setViewName(\"index\");\n+            modelAndView.addObject(\"message\", WRONG_SIGNIN);\n+        }\n         return modelAndView;\n     }\n \n     @PostMapping(\"/user\")\n-    public ModelAndView addNewUser(@ModelAttribute(\"userJSP\") User user) {\n-        ModelAndView modelAndView = new ModelAndView();\n-        if (userService.addNewUser(user)) {\n-            modelAndView.setViewName(\"welcome\");\n+    public ModelAndView addUser(@ModelAttribute(\"userJSP\") User user, ModelAndView modelAndView) {\n+        User newUser = userService.addUser(user);\n+        if (null != newUser) {\n+            modelAndView.setViewName(getViewName(newUser));\n             modelAndView.addObject(\"userJSP\", user);\n         } else {\n             modelAndView.setViewName(\"regist\");\n             modelAndView.addObject(\"newUser\", user);\n-            modelAndView.addObject(\"registerErrorMessage\", \"User with this login is already exists.\");\n+            modelAndView.addObject(\"message\", WRONG_SIGNUP);\n         }\n         return modelAndView;\n     }\n+\n+    String getViewName(User newUser) {","path":"src/main/java/com/epam/onlineshop/controllers/UserController.java","position":null,"original_position":70,"commit_id":"d0f944cdae3ac010116117012d0adb9ecff853c2","original_commit_id":"f7e10bfc6c7e8c70b1b2ed12f5b1978bfbbf0f38","user":{"login":"goponenkoev","id":29695146,"node_id":"MDQ6VXNlcjI5Njk1MTQ2","avatar_url":"https://avatars0.githubusercontent.com/u/29695146?v=4","gravatar_id":"","url":"https://api.github.com/users/goponenkoev","html_url":"https://github.com/goponenkoev","followers_url":"https://api.github.com/users/goponenkoev/followers","following_url":"https://api.github.com/users/goponenkoev/following{/other_user}","gists_url":"https://api.github.com/users/goponenkoev/gists{/gist_id}","starred_url":"https://api.github.com/users/goponenkoev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goponenkoev/subscriptions","organizations_url":"https://api.github.com/users/goponenkoev/orgs","repos_url":"https://api.github.com/users/goponenkoev/repos","events_url":"https://api.github.com/users/goponenkoev/events{/privacy}","received_events_url":"https://api.github.com/users/goponenkoev/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2018-07-10T08:50:15Z","updated_at":"2018-07-10T08:50:15Z","html_url":"https://github.com/Gradder/OnlineShop/pull/8#discussion_r201263459","pull_request_url":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Gradder/OnlineShop/pulls/comments/201263459"},"html":{"href":"https://github.com/Gradder/OnlineShop/pull/8#discussion_r201263459"},"pull_request":{"href":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8"}},"in_reply_to_id":201079549},"pull_request":{"url":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8","id":200077880,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwMDc3ODgw","html_url":"https://github.com/Gradder/OnlineShop/pull/8","diff_url":"https://github.com/Gradder/OnlineShop/pull/8.diff","patch_url":"https://github.com/Gradder/OnlineShop/pull/8.patch","issue_url":"https://api.github.com/repos/Gradder/OnlineShop/issues/8","number":8,"state":"open","locked":false,"title":"Added checking in registration form","user":{"login":"goponenkoev","id":29695146,"node_id":"MDQ6VXNlcjI5Njk1MTQ2","avatar_url":"https://avatars0.githubusercontent.com/u/29695146?v=4","gravatar_id":"","url":"https://api.github.com/users/goponenkoev","html_url":"https://github.com/goponenkoev","followers_url":"https://api.github.com/users/goponenkoev/followers","following_url":"https://api.github.com/users/goponenkoev/following{/other_user}","gists_url":"https://api.github.com/users/goponenkoev/gists{/gist_id}","starred_url":"https://api.github.com/users/goponenkoev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goponenkoev/subscriptions","organizations_url":"https://api.github.com/users/goponenkoev/orgs","repos_url":"https://api.github.com/users/goponenkoev/repos","events_url":"https://api.github.com/users/goponenkoev/events{/privacy}","received_events_url":"https://api.github.com/users/goponenkoev/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-09T12:03:11Z","updated_at":"2018-07-10T08:50:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0955ac8226baaf75d8a791bb6f976f7eec249cfd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8/commits","review_comments_url":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8/comments","review_comment_url":"https://api.github.com/repos/Gradder/OnlineShop/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Gradder/OnlineShop/issues/8/comments","statuses_url":"https://api.github.com/repos/Gradder/OnlineShop/statuses/d0f944cdae3ac010116117012d0adb9ecff853c2","head":{"label":"goponenkoev:master","ref":"master","sha":"d0f944cdae3ac010116117012d0adb9ecff853c2","user":{"login":"goponenkoev","id":29695146,"node_id":"MDQ6VXNlcjI5Njk1MTQ2","avatar_url":"https://avatars0.githubusercontent.com/u/29695146?v=4","gravatar_id":"","url":"https://api.github.com/users/goponenkoev","html_url":"https://github.com/goponenkoev","followers_url":"https://api.github.com/users/goponenkoev/followers","following_url":"https://api.github.com/users/goponenkoev/following{/other_user}","gists_url":"https://api.github.com/users/goponenkoev/gists{/gist_id}","starred_url":"https://api.github.com/users/goponenkoev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goponenkoev/subscriptions","organizations_url":"https://api.github.com/users/goponenkoev/orgs","repos_url":"https://api.github.com/users/goponenkoev/repos","events_url":"https://api.github.com/users/goponenkoev/events{/privacy}","received_events_url":"https://api.github.com/users/goponenkoev/received_events","type":"User","site_admin":false},"repo":{"id":140020220,"node_id":"MDEwOlJlcG9zaXRvcnkxNDAwMjAyMjA=","name":"OnlineShop","full_name":"goponenkoev/OnlineShop","owner":{"login":"goponenkoev","id":29695146,"node_id":"MDQ6VXNlcjI5Njk1MTQ2","avatar_url":"https://avatars0.githubusercontent.com/u/29695146?v=4","gravatar_id":"","url":"https://api.github.com/users/goponenkoev","html_url":"https://github.com/goponenkoev","followers_url":"https://api.github.com/users/goponenkoev/followers","following_url":"https://api.github.com/users/goponenkoev/following{/other_user}","gists_url":"https://api.github.com/users/goponenkoev/gists{/gist_id}","starred_url":"https://api.github.com/users/goponenkoev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goponenkoev/subscriptions","organizations_url":"https://api.github.com/users/goponenkoev/orgs","repos_url":"https://api.github.com/users/goponenkoev/repos","events_url":"https://api.github.com/users/goponenkoev/events{/privacy}","received_events_url":"https://api.github.com/users/goponenkoev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/goponenkoev/OnlineShop","description":"First project for 2-weeks challenge from EPAM","fork":true,"url":"https://api.github.com/repos/goponenkoev/OnlineShop","forks_url":"https://api.github.com/repos/goponenkoev/OnlineShop/forks","keys_url":"https://api.github.com/repos/goponenkoev/OnlineShop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/goponenkoev/OnlineShop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/goponenkoev/OnlineShop/teams","hooks_url":"https://api.github.com/repos/goponenkoev/OnlineShop/hooks","issue_events_url":"https://api.github.com/repos/goponenkoev/OnlineShop/issues/events{/number}","events_url":"https://api.github.com/repos/goponenkoev/OnlineShop/events","assignees_url":"https://api.github.com/repos/goponenkoev/OnlineShop/assignees{/user}","branches_url":"https://api.github.com/repos/goponenkoev/OnlineShop/branches{/branch}","tags_url":"https://api.github.com/repos/goponenkoev/OnlineShop/tags","blobs_url":"https://api.github.com/repos/goponenkoev/OnlineShop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/goponenkoev/OnlineShop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/goponenkoev/OnlineShop/git/refs{/sha}","trees_url":"https://api.github.com/repos/goponenkoev/OnlineShop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/goponenkoev/OnlineShop/statuses/{sha}","languages_url":"https://api.github.com/repos/goponenkoev/OnlineShop/languages","stargazers_url":"https://api.github.com/repos/goponenkoev/OnlineShop/stargazers","contributors_url":"https://api.github.com/repos/goponenkoev/OnlineShop/contributors","subscribers_url":"https://api.github.com/repos/goponenkoev/OnlineShop/subscribers","subscription_url":"https://api.github.com/repos/goponenkoev/OnlineShop/subscription","commits_url":"https://api.github.com/repos/goponenkoev/OnlineShop/commits{/sha}","git_commits_url":"https://api.github.com/repos/goponenkoev/OnlineShop/git/commits{/sha}","comments_url":"https://api.github.com/repos/goponenkoev/OnlineShop/comments{/number}","issue_comment_url":"https://api.github.com/repos/goponenkoev/OnlineShop/issues/comments{/number}","contents_url":"https://api.github.com/repos/goponenkoev/OnlineShop/contents/{+path}","compare_url":"https://api.github.com/repos/goponenkoev/OnlineShop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/goponenkoev/OnlineShop/merges","archive_url":"https://api.github.com/repos/goponenkoev/OnlineShop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/goponenkoev/OnlineShop/downloads","issues_url":"https://api.github.com/repos/goponenkoev/OnlineShop/issues{/number}","pulls_url":"https://api.github.com/repos/goponenkoev/OnlineShop/pulls{/number}","milestones_url":"https://api.github.com/repos/goponenkoev/OnlineShop/milestones{/number}","notifications_url":"https://api.github.com/repos/goponenkoev/OnlineShop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/goponenkoev/OnlineShop/labels{/name}","releases_url":"https://api.github.com/repos/goponenkoev/OnlineShop/releases{/id}","deployments_url":"https://api.github.com/repos/goponenkoev/OnlineShop/deployments","created_at":"2018-07-06T18:54:48Z","updated_at":"2018-07-10T08:49:15Z","pushed_at":"2018-07-10T08:49:13Z","git_url":"git://github.com/goponenkoev/OnlineShop.git","ssh_url":"git@github.com:goponenkoev/OnlineShop.git","clone_url":"https://github.com/goponenkoev/OnlineShop.git","svn_url":"https://github.com/goponenkoev/OnlineShop","homepage":null,"size":98,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Gradder:master","ref":"master","sha":"ca818b2c89beb801d8783f9461eac4ef80e6bc9a","user":{"login":"Gradder","id":9297167,"node_id":"MDQ6VXNlcjkyOTcxNjc=","avatar_url":"https://avatars0.githubusercontent.com/u/9297167?v=4","gravatar_id":"","url":"https://api.github.com/users/Gradder","html_url":"https://github.com/Gradder","followers_url":"https://api.github.com/users/Gradder/followers","following_url":"https://api.github.com/users/Gradder/following{/other_user}","gists_url":"https://api.github.com/users/Gradder/gists{/gist_id}","starred_url":"https://api.github.com/users/Gradder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gradder/subscriptions","organizations_url":"https://api.github.com/users/Gradder/orgs","repos_url":"https://api.github.com/users/Gradder/repos","events_url":"https://api.github.com/users/Gradder/events{/privacy}","received_events_url":"https://api.github.com/users/Gradder/received_events","type":"User","site_admin":false},"repo":{"id":139882398,"node_id":"MDEwOlJlcG9zaXRvcnkxMzk4ODIzOTg=","name":"OnlineShop","full_name":"Gradder/OnlineShop","owner":{"login":"Gradder","id":9297167,"node_id":"MDQ6VXNlcjkyOTcxNjc=","avatar_url":"https://avatars0.githubusercontent.com/u/9297167?v=4","gravatar_id":"","url":"https://api.github.com/users/Gradder","html_url":"https://github.com/Gradder","followers_url":"https://api.github.com/users/Gradder/followers","following_url":"https://api.github.com/users/Gradder/following{/other_user}","gists_url":"https://api.github.com/users/Gradder/gists{/gist_id}","starred_url":"https://api.github.com/users/Gradder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gradder/subscriptions","organizations_url":"https://api.github.com/users/Gradder/orgs","repos_url":"https://api.github.com/users/Gradder/repos","events_url":"https://api.github.com/users/Gradder/events{/privacy}","received_events_url":"https://api.github.com/users/Gradder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Gradder/OnlineShop","description":"First project for 2-weeks challenge from EPAM","fork":false,"url":"https://api.github.com/repos/Gradder/OnlineShop","forks_url":"https://api.github.com/repos/Gradder/OnlineShop/forks","keys_url":"https://api.github.com/repos/Gradder/OnlineShop/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Gradder/OnlineShop/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Gradder/OnlineShop/teams","hooks_url":"https://api.github.com/repos/Gradder/OnlineShop/hooks","issue_events_url":"https://api.github.com/repos/Gradder/OnlineShop/issues/events{/number}","events_url":"https://api.github.com/repos/Gradder/OnlineShop/events","assignees_url":"https://api.github.com/repos/Gradder/OnlineShop/assignees{/user}","branches_url":"https://api.github.com/repos/Gradder/OnlineShop/branches{/branch}","tags_url":"https://api.github.com/repos/Gradder/OnlineShop/tags","blobs_url":"https://api.github.com/repos/Gradder/OnlineShop/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Gradder/OnlineShop/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Gradder/OnlineShop/git/refs{/sha}","trees_url":"https://api.github.com/repos/Gradder/OnlineShop/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Gradder/OnlineShop/statuses/{sha}","languages_url":"https://api.github.com/repos/Gradder/OnlineShop/languages","stargazers_url":"https://api.github.com/repos/Gradder/OnlineShop/stargazers","contributors_url":"https://api.github.com/repos/Gradder/OnlineShop/contributors","subscribers_url":"https://api.github.com/repos/Gradder/OnlineShop/subscribers","subscription_url":"https://api.github.com/repos/Gradder/OnlineShop/subscription","commits_url":"https://api.github.com/repos/Gradder/OnlineShop/commits{/sha}","git_commits_url":"https://api.github.com/repos/Gradder/OnlineShop/git/commits{/sha}","comments_url":"https://api.github.com/repos/Gradder/OnlineShop/comments{/number}","issue_comment_url":"https://api.github.com/repos/Gradder/OnlineShop/issues/comments{/number}","contents_url":"https://api.github.com/repos/Gradder/OnlineShop/contents/{+path}","compare_url":"https://api.github.com/repos/Gradder/OnlineShop/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Gradder/OnlineShop/merges","archive_url":"https://api.github.com/repos/Gradder/OnlineShop/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Gradder/OnlineShop/downloads","issues_url":"https://api.github.com/repos/Gradder/OnlineShop/issues{/number}","pulls_url":"https://api.github.com/repos/Gradder/OnlineShop/pulls{/number}","milestones_url":"https://api.github.com/repos/Gradder/OnlineShop/milestones{/number}","notifications_url":"https://api.github.com/repos/Gradder/OnlineShop/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Gradder/OnlineShop/labels{/name}","releases_url":"https://api.github.com/repos/Gradder/OnlineShop/releases{/id}","deployments_url":"https://api.github.com/repos/Gradder/OnlineShop/deployments","created_at":"2018-07-05T17:44:43Z","updated_at":"2018-07-09T13:18:33Z","pushed_at":"2018-07-10T08:49:14Z","git_url":"git://github.com/Gradder/OnlineShop.git","ssh_url":"git@github.com:Gradder/OnlineShop.git","clone_url":"https://github.com/Gradder/OnlineShop.git","svn_url":"https://github.com/Gradder/OnlineShop","homepage":null,"size":88,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8"},"html":{"href":"https://github.com/Gradder/OnlineShop/pull/8"},"issue":{"href":"https://api.github.com/repos/Gradder/OnlineShop/issues/8"},"comments":{"href":"https://api.github.com/repos/Gradder/OnlineShop/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/Gradder/OnlineShop/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Gradder/OnlineShop/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/Gradder/OnlineShop/statuses/d0f944cdae3ac010116117012d0adb9ecff853c2"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"goponenkoev"}}