{"action":"created","comment":{"url":"https://api.github.com/repos/infectnet/infectnet-server/pulls/comments/83189840","pull_request_review_id":4046914,"id":83189840,"diff_hunk":"@@ -1,22 +1,105 @@\n package io.infectnet.server.service.impl;\n \n+import io.infectnet.server.persistence.Token;\n+import io.infectnet.server.persistence.TokenStorage;\n+import io.infectnet.server.persistence.User;\n+import io.infectnet.server.persistence.UserStorage;\n import io.infectnet.server.service.UserDTO;\n import io.infectnet.server.service.UserService;\n \n+import java.time.LocalDateTime;\n+import java.util.Objects;\n+import java.util.Optional;\n+\n public class UserServiceImpl implements UserService {\n \n+    private final UserStorage userStorage;\n+\n+    private final TokenStorage tokenStorage;\n+\n+    private final ConverterServiceImpl converterService;\n+\n+    public UserServiceImpl(){\n+        converterService = null;\n+        tokenStorage = null;\n+        userStorage = null;\n+    }\n+\n+    public UserServiceImpl(UserStorage userStorage, TokenStorage tokenStorage, ConverterServiceImpl converterService) {\n+        this.userStorage = userStorage;\n+        this.tokenStorage = tokenStorage;\n+        this.converterService = converterService;\n+    }\n+\n+    /**\n+     * Registers the new user in. Checks if the token has not expired yet and the username is unique,\n+     * and whether or not the password is valid according to the specified rules:\n+     *      minimum length of 8 characters\n+     *      must contain at least one number\n+     *      must contain at least one uppercase letter.\n+     * If authentication fails no new user will be stored, otherwise a new User is stored\n+     * with the username, the email, the password and the date of the registration now produced.\n+     *\n+     * @param token the token from the current registration\n+     * @param email the email address from the current registration\n+     * @param username the username from the current registration\n+     * @param password the password from the current registration\n+     * @return the Optional containing the UserDTO made from the created user\n+     */\n     @Override\n-    public UserDTO register(String token, String username, String password) {\n-        return null;\n+    public Optional<UserDTO> register(String token, String email, String username, String password) {\n+        if(tokenIsValid(token) && emailIsUnique(email) && usernameIsUnique(username) && passwordIsValid(password)){","path":"server-core/service/src/main/java/io/infectnet/server/service/impl/UserServiceImpl.java","position":53,"original_position":53,"commit_id":"5c6900f52ae55469b99c6901c7082c92171fff19","original_commit_id":"5c6900f52ae55469b99c6901c7082c92171fff19","user":{"login":"battila7","id":11032092,"avatar_url":"https://avatars.githubusercontent.com/u/11032092?v=3","gravatar_id":"","url":"https://api.github.com/users/battila7","html_url":"https://github.com/battila7","followers_url":"https://api.github.com/users/battila7/followers","following_url":"https://api.github.com/users/battila7/following{/other_user}","gists_url":"https://api.github.com/users/battila7/gists{/gist_id}","starred_url":"https://api.github.com/users/battila7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/battila7/subscriptions","organizations_url":"https://api.github.com/users/battila7/orgs","repos_url":"https://api.github.com/users/battila7/repos","events_url":"https://api.github.com/users/battila7/events{/privacy}","received_events_url":"https://api.github.com/users/battila7/received_events","type":"User","site_admin":false},"body":"Extract the contents of  this `if` into a separate method that checks for validity. Also modify the order of the clauses, so `tokenIsValid` comes first, followed by `passwordIsValid`.","created_at":"2016-10-13T10:51:43Z","updated_at":"2016-10-13T10:51:43Z","html_url":"https://github.com/infectnet/infectnet-server/pull/26#discussion_r83189840","pull_request_url":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/infectnet/infectnet-server/pulls/comments/83189840"},"html":{"href":"https://github.com/infectnet/infectnet-server/pull/26#discussion_r83189840"},"pull_request":{"href":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26","id":89177356,"html_url":"https://github.com/infectnet/infectnet-server/pull/26","diff_url":"https://github.com/infectnet/infectnet-server/pull/26.diff","patch_url":"https://github.com/infectnet/infectnet-server/pull/26.patch","issue_url":"https://api.github.com/repos/infectnet/infectnet-server/issues/26","number":26,"state":"open","locked":false,"title":"Registration using token - closes #3","user":{"login":"szabom5","id":11292259,"avatar_url":"https://avatars.githubusercontent.com/u/11292259?v=3","gravatar_id":"","url":"https://api.github.com/users/szabom5","html_url":"https://github.com/szabom5","followers_url":"https://api.github.com/users/szabom5/followers","following_url":"https://api.github.com/users/szabom5/following{/other_user}","gists_url":"https://api.github.com/users/szabom5/gists{/gist_id}","starred_url":"https://api.github.com/users/szabom5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szabom5/subscriptions","organizations_url":"https://api.github.com/users/szabom5/orgs","repos_url":"https://api.github.com/users/szabom5/repos","events_url":"https://api.github.com/users/szabom5/events{/privacy}","received_events_url":"https://api.github.com/users/szabom5/received_events","type":"User","site_admin":false},"body":"Tests to be done later.","created_at":"2016-10-13T10:43:43Z","updated_at":"2016-10-13T10:54:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c492a387f2a75e5e8eda83251904778484c41db5","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/infectnet/infectnet-server/milestones/1","html_url":"https://github.com/infectnet/infectnet-server/milestones/Alpha%20Version","labels_url":"https://api.github.com/repos/infectnet/infectnet-server/milestones/1/labels","id":2029227,"number":1,"title":"Alpha Version","description":"The alpha version consists of the following features:\r\n\r\n * Login/Register/Continue\r\n * Working game loop\r\n * Proof of Concept DSL\r\n * One working worker (pun intended)","creator":{"login":"battila7","id":11032092,"avatar_url":"https://avatars.githubusercontent.com/u/11032092?v=3","gravatar_id":"","url":"https://api.github.com/users/battila7","html_url":"https://github.com/battila7","followers_url":"https://api.github.com/users/battila7/followers","following_url":"https://api.github.com/users/battila7/following{/other_user}","gists_url":"https://api.github.com/users/battila7/gists{/gist_id}","starred_url":"https://api.github.com/users/battila7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/battila7/subscriptions","organizations_url":"https://api.github.com/users/battila7/orgs","repos_url":"https://api.github.com/users/battila7/repos","events_url":"https://api.github.com/users/battila7/events{/privacy}","received_events_url":"https://api.github.com/users/battila7/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":12,"state":"open","created_at":"2016-09-26T15:39:58Z","updated_at":"2016-10-13T10:43:50Z","due_on":"2016-11-01T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26/commits","review_comments_url":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26/comments","review_comment_url":"https://api.github.com/repos/infectnet/infectnet-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/infectnet/infectnet-server/issues/26/comments","statuses_url":"https://api.github.com/repos/infectnet/infectnet-server/statuses/5c6900f52ae55469b99c6901c7082c92171fff19","head":{"label":"infectnet:registration-using-token-#3","ref":"registration-using-token-#3","sha":"5c6900f52ae55469b99c6901c7082c92171fff19","user":{"login":"infectnet","id":22404572,"avatar_url":"https://avatars.githubusercontent.com/u/22404572?v=3","gravatar_id":"","url":"https://api.github.com/users/infectnet","html_url":"https://github.com/infectnet","followers_url":"https://api.github.com/users/infectnet/followers","following_url":"https://api.github.com/users/infectnet/following{/other_user}","gists_url":"https://api.github.com/users/infectnet/gists{/gist_id}","starred_url":"https://api.github.com/users/infectnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infectnet/subscriptions","organizations_url":"https://api.github.com/users/infectnet/orgs","repos_url":"https://api.github.com/users/infectnet/repos","events_url":"https://api.github.com/users/infectnet/events{/privacy}","received_events_url":"https://api.github.com/users/infectnet/received_events","type":"Organization","site_admin":false},"repo":{"id":69064135,"name":"infectnet-server","full_name":"infectnet/infectnet-server","owner":{"login":"infectnet","id":22404572,"avatar_url":"https://avatars.githubusercontent.com/u/22404572?v=3","gravatar_id":"","url":"https://api.github.com/users/infectnet","html_url":"https://github.com/infectnet","followers_url":"https://api.github.com/users/infectnet/followers","following_url":"https://api.github.com/users/infectnet/following{/other_user}","gists_url":"https://api.github.com/users/infectnet/gists{/gist_id}","starred_url":"https://api.github.com/users/infectnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infectnet/subscriptions","organizations_url":"https://api.github.com/users/infectnet/orgs","repos_url":"https://api.github.com/users/infectnet/repos","events_url":"https://api.github.com/users/infectnet/events{/privacy}","received_events_url":"https://api.github.com/users/infectnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/infectnet/infectnet-server","description":"The game server of InfectNet.","fork":false,"url":"https://api.github.com/repos/infectnet/infectnet-server","forks_url":"https://api.github.com/repos/infectnet/infectnet-server/forks","keys_url":"https://api.github.com/repos/infectnet/infectnet-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/infectnet/infectnet-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/infectnet/infectnet-server/teams","hooks_url":"https://api.github.com/repos/infectnet/infectnet-server/hooks","issue_events_url":"https://api.github.com/repos/infectnet/infectnet-server/issues/events{/number}","events_url":"https://api.github.com/repos/infectnet/infectnet-server/events","assignees_url":"https://api.github.com/repos/infectnet/infectnet-server/assignees{/user}","branches_url":"https://api.github.com/repos/infectnet/infectnet-server/branches{/branch}","tags_url":"https://api.github.com/repos/infectnet/infectnet-server/tags","blobs_url":"https://api.github.com/repos/infectnet/infectnet-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/infectnet/infectnet-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/infectnet/infectnet-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/infectnet/infectnet-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/infectnet/infectnet-server/statuses/{sha}","languages_url":"https://api.github.com/repos/infectnet/infectnet-server/languages","stargazers_url":"https://api.github.com/repos/infectnet/infectnet-server/stargazers","contributors_url":"https://api.github.com/repos/infectnet/infectnet-server/contributors","subscribers_url":"https://api.github.com/repos/infectnet/infectnet-server/subscribers","subscription_url":"https://api.github.com/repos/infectnet/infectnet-server/subscription","commits_url":"https://api.github.com/repos/infectnet/infectnet-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/infectnet/infectnet-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/infectnet/infectnet-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/infectnet/infectnet-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/infectnet/infectnet-server/contents/{+path}","compare_url":"https://api.github.com/repos/infectnet/infectnet-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/infectnet/infectnet-server/merges","archive_url":"https://api.github.com/repos/infectnet/infectnet-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/infectnet/infectnet-server/downloads","issues_url":"https://api.github.com/repos/infectnet/infectnet-server/issues{/number}","pulls_url":"https://api.github.com/repos/infectnet/infectnet-server/pulls{/number}","milestones_url":"https://api.github.com/repos/infectnet/infectnet-server/milestones{/number}","notifications_url":"https://api.github.com/repos/infectnet/infectnet-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/infectnet/infectnet-server/labels{/name}","releases_url":"https://api.github.com/repos/infectnet/infectnet-server/releases{/id}","deployments_url":"https://api.github.com/repos/infectnet/infectnet-server/deployments","created_at":"2016-09-23T22:13:08Z","updated_at":"2016-09-25T14:31:42Z","pushed_at":"2016-10-13T10:43:43Z","git_url":"git://github.com/infectnet/infectnet-server.git","ssh_url":"git@github.com:infectnet/infectnet-server.git","clone_url":"https://github.com/infectnet/infectnet-server.git","svn_url":"https://github.com/infectnet/infectnet-server","homepage":"","size":135,"stargazers_count":3,"watchers_count":3,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":3,"default_branch":"master"}},"base":{"label":"infectnet:develop","ref":"develop","sha":"4ef6ac2ccb8ba131f221031f75fc7400b0e7f49a","user":{"login":"infectnet","id":22404572,"avatar_url":"https://avatars.githubusercontent.com/u/22404572?v=3","gravatar_id":"","url":"https://api.github.com/users/infectnet","html_url":"https://github.com/infectnet","followers_url":"https://api.github.com/users/infectnet/followers","following_url":"https://api.github.com/users/infectnet/following{/other_user}","gists_url":"https://api.github.com/users/infectnet/gists{/gist_id}","starred_url":"https://api.github.com/users/infectnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infectnet/subscriptions","organizations_url":"https://api.github.com/users/infectnet/orgs","repos_url":"https://api.github.com/users/infectnet/repos","events_url":"https://api.github.com/users/infectnet/events{/privacy}","received_events_url":"https://api.github.com/users/infectnet/received_events","type":"Organization","site_admin":false},"repo":{"id":69064135,"name":"infectnet-server","full_name":"infectnet/infectnet-server","owner":{"login":"infectnet","id":22404572,"avatar_url":"https://avatars.githubusercontent.com/u/22404572?v=3","gravatar_id":"","url":"https://api.github.com/users/infectnet","html_url":"https://github.com/infectnet","followers_url":"https://api.github.com/users/infectnet/followers","following_url":"https://api.github.com/users/infectnet/following{/other_user}","gists_url":"https://api.github.com/users/infectnet/gists{/gist_id}","starred_url":"https://api.github.com/users/infectnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infectnet/subscriptions","organizations_url":"https://api.github.com/users/infectnet/orgs","repos_url":"https://api.github.com/users/infectnet/repos","events_url":"https://api.github.com/users/infectnet/events{/privacy}","received_events_url":"https://api.github.com/users/infectnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/infectnet/infectnet-server","description":"The game server of InfectNet.","fork":false,"url":"https://api.github.com/repos/infectnet/infectnet-server","forks_url":"https://api.github.com/repos/infectnet/infectnet-server/forks","keys_url":"https://api.github.com/repos/infectnet/infectnet-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/infectnet/infectnet-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/infectnet/infectnet-server/teams","hooks_url":"https://api.github.com/repos/infectnet/infectnet-server/hooks","issue_events_url":"https://api.github.com/repos/infectnet/infectnet-server/issues/events{/number}","events_url":"https://api.github.com/repos/infectnet/infectnet-server/events","assignees_url":"https://api.github.com/repos/infectnet/infectnet-server/assignees{/user}","branches_url":"https://api.github.com/repos/infectnet/infectnet-server/branches{/branch}","tags_url":"https://api.github.com/repos/infectnet/infectnet-server/tags","blobs_url":"https://api.github.com/repos/infectnet/infectnet-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/infectnet/infectnet-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/infectnet/infectnet-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/infectnet/infectnet-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/infectnet/infectnet-server/statuses/{sha}","languages_url":"https://api.github.com/repos/infectnet/infectnet-server/languages","stargazers_url":"https://api.github.com/repos/infectnet/infectnet-server/stargazers","contributors_url":"https://api.github.com/repos/infectnet/infectnet-server/contributors","subscribers_url":"https://api.github.com/repos/infectnet/infectnet-server/subscribers","subscription_url":"https://api.github.com/repos/infectnet/infectnet-server/subscription","commits_url":"https://api.github.com/repos/infectnet/infectnet-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/infectnet/infectnet-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/infectnet/infectnet-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/infectnet/infectnet-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/infectnet/infectnet-server/contents/{+path}","compare_url":"https://api.github.com/repos/infectnet/infectnet-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/infectnet/infectnet-server/merges","archive_url":"https://api.github.com/repos/infectnet/infectnet-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/infectnet/infectnet-server/downloads","issues_url":"https://api.github.com/repos/infectnet/infectnet-server/issues{/number}","pulls_url":"https://api.github.com/repos/infectnet/infectnet-server/pulls{/number}","milestones_url":"https://api.github.com/repos/infectnet/infectnet-server/milestones{/number}","notifications_url":"https://api.github.com/repos/infectnet/infectnet-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/infectnet/infectnet-server/labels{/name}","releases_url":"https://api.github.com/repos/infectnet/infectnet-server/releases{/id}","deployments_url":"https://api.github.com/repos/infectnet/infectnet-server/deployments","created_at":"2016-09-23T22:13:08Z","updated_at":"2016-09-25T14:31:42Z","pushed_at":"2016-10-13T10:43:43Z","git_url":"git://github.com/infectnet/infectnet-server.git","ssh_url":"git@github.com:infectnet/infectnet-server.git","clone_url":"https://github.com/infectnet/infectnet-server.git","svn_url":"https://github.com/infectnet/infectnet-server","homepage":"","size":135,"stargazers_count":3,"watchers_count":3,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26"},"html":{"href":"https://github.com/infectnet/infectnet-server/pull/26"},"issue":{"href":"https://api.github.com/repos/infectnet/infectnet-server/issues/26"},"comments":{"href":"https://api.github.com/repos/infectnet/infectnet-server/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/infectnet/infectnet-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/infectnet/infectnet-server/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/infectnet/infectnet-server/statuses/5c6900f52ae55469b99c6901c7082c92171fff19"}}}}
{"actor":{"display_login":"battila7"}}