{"action":"created","comment":{"url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/comments/91542217","pull_request_review_id":12050857,"id":91542217,"diff_hunk":"@@ -0,0 +1,103 @@\n+﻿using Microsoft.AspNetCore.Builder;\n+using Microsoft.AspNetCore.Identity;\n+using Microsoft.Extensions.Localization;\n+using Microsoft.Extensions.Options;\n+using Orchard.Users.Models;\n+using System;\n+using System.Threading.Tasks;\n+\n+namespace Orchard.Users.Services\n+{\n+    public class UserService: IUserService\n+    {\n+        private readonly UserManager<User> _userManager;\n+        private readonly IOptions<IdentityOptions> _identityOptions;\n+        private readonly IStringLocalizer<UserService> T;\n+        public UserService(UserManager<User> userManager, IOptions<IdentityOptions> identityOptions, IStringLocalizer<UserService> stringLocalizer)\n+        {\n+            _userManager = userManager;\n+            _identityOptions = identityOptions;\n+            T = stringLocalizer;\n+        }\n+\n+        public async Task<bool> CreateUserAsync(User user, string password, Action<string, string> reportError)\n+        {\n+            bool result = true;\n+            if (string.IsNullOrWhiteSpace(user.UserName))\n+            {\n+                reportError(\"UserName\", T[\"You must provide an user name.\"]);\n+                result = false;\n+            }\n+            if (string.IsNullOrWhiteSpace(user.UserName))\n+            {\n+                reportError(\"Password\", T[\"You must provide a password.\"]);\n+                result = false;\n+            }\n+            if (string.IsNullOrWhiteSpace(user.Email))\n+            {\n+                reportError(\"Email\", T[\"You must provide an email.\"]);","path":"src/Orchard.Cms.Web/Modules/Orchard.Users/Services/UserService.cs","position":38,"original_position":38,"commit_id":"f0d7b7d26911b83915adce5893a32265535d9b8d","original_commit_id":"f0d7b7d26911b83915adce5893a32265535d9b8d","user":{"login":"sebastienros","id":1165805,"avatar_url":"https://avatars.githubusercontent.com/u/1165805?v=3","gravatar_id":"","url":"https://api.github.com/users/sebastienros","html_url":"https://github.com/sebastienros","followers_url":"https://api.github.com/users/sebastienros/followers","following_url":"https://api.github.com/users/sebastienros/following{/other_user}","gists_url":"https://api.github.com/users/sebastienros/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastienros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastienros/subscriptions","organizations_url":"https://api.github.com/users/sebastienros/orgs","repos_url":"https://api.github.com/users/sebastienros/repos","events_url":"https://api.github.com/users/sebastienros/events{/privacy}","received_events_url":"https://api.github.com/users/sebastienros/received_events","type":"User","site_admin":false},"body":"Same here","created_at":"2016-12-08T15:55:23Z","updated_at":"2016-12-08T15:57:37Z","html_url":"https://github.com/OrchardCMS/Orchard2/pull/394#discussion_r91542217","pull_request_url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394","_links":{"self":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/comments/91542217"},"html":{"href":"https://github.com/OrchardCMS/Orchard2/pull/394#discussion_r91542217"},"pull_request":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394"}}},"pull_request":{"url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394","id":97131660,"html_url":"https://github.com/OrchardCMS/Orchard2/pull/394","diff_url":"https://github.com/OrchardCMS/Orchard2/pull/394.diff","patch_url":"https://github.com/OrchardCMS/Orchard2/pull/394.patch","issue_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/394","number":394,"state":"open","locked":false,"title":"#388 CreateUser Command","user":{"login":"jersiovic","id":4950766,"avatar_url":"https://avatars.githubusercontent.com/u/4950766?v=3","gravatar_id":"","url":"https://api.github.com/users/jersiovic","html_url":"https://github.com/jersiovic","followers_url":"https://api.github.com/users/jersiovic/followers","following_url":"https://api.github.com/users/jersiovic/following{/other_user}","gists_url":"https://api.github.com/users/jersiovic/gists{/gist_id}","starred_url":"https://api.github.com/users/jersiovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jersiovic/subscriptions","organizations_url":"https://api.github.com/users/jersiovic/orgs","repos_url":"https://api.github.com/users/jersiovic/repos","events_url":"https://api.github.com/users/jersiovic/events{/privacy}","received_events_url":"https://api.github.com/users/jersiovic/received_events","type":"User","site_admin":false},"body":"Adds the CreateUser command described on this issue: https://github.com/OrchardCMS/Orchard2/issues/388\r\n\r\nTo avoid repeated code validating data for a new user in Create User Command, in SetupEventHandler, in AccountController and in AdminController I refacored code moving this validation code to a new class called UserService.cs .\r\nIf do you agree with that we can also centralize in User service logic for validation and modification of an user that currently is done in AdminController.","created_at":"2016-12-08T14:29:12Z","updated_at":"2016-12-08T15:57:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e66d86a76d8435adec69a0712df7a212fe8356d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394/commits","review_comments_url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394/comments","review_comment_url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/394/comments","statuses_url":"https://api.github.com/repos/OrchardCMS/Orchard2/statuses/f0d7b7d26911b83915adce5893a32265535d9b8d","head":{"label":"OrchardCMS:#388_createUserCommand","ref":"#388_createUserCommand","sha":"f0d7b7d26911b83915adce5893a32265535d9b8d","user":{"login":"OrchardCMS","id":1159247,"avatar_url":"https://avatars.githubusercontent.com/u/1159247?v=3","gravatar_id":"","url":"https://api.github.com/users/OrchardCMS","html_url":"https://github.com/OrchardCMS","followers_url":"https://api.github.com/users/OrchardCMS/followers","following_url":"https://api.github.com/users/OrchardCMS/following{/other_user}","gists_url":"https://api.github.com/users/OrchardCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/OrchardCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrchardCMS/subscriptions","organizations_url":"https://api.github.com/users/OrchardCMS/orgs","repos_url":"https://api.github.com/users/OrchardCMS/repos","events_url":"https://api.github.com/users/OrchardCMS/events{/privacy}","received_events_url":"https://api.github.com/users/OrchardCMS/received_events","type":"Organization","site_admin":false},"repo":{"id":26884725,"name":"Orchard2","full_name":"OrchardCMS/Orchard2","owner":{"login":"OrchardCMS","id":1159247,"avatar_url":"https://avatars.githubusercontent.com/u/1159247?v=3","gravatar_id":"","url":"https://api.github.com/users/OrchardCMS","html_url":"https://github.com/OrchardCMS","followers_url":"https://api.github.com/users/OrchardCMS/followers","following_url":"https://api.github.com/users/OrchardCMS/following{/other_user}","gists_url":"https://api.github.com/users/OrchardCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/OrchardCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrchardCMS/subscriptions","organizations_url":"https://api.github.com/users/OrchardCMS/orgs","repos_url":"https://api.github.com/users/OrchardCMS/repos","events_url":"https://api.github.com/users/OrchardCMS/events{/privacy}","received_events_url":"https://api.github.com/users/OrchardCMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OrchardCMS/Orchard2","description":"Orchard vNext","fork":false,"url":"https://api.github.com/repos/OrchardCMS/Orchard2","forks_url":"https://api.github.com/repos/OrchardCMS/Orchard2/forks","keys_url":"https://api.github.com/repos/OrchardCMS/Orchard2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OrchardCMS/Orchard2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OrchardCMS/Orchard2/teams","hooks_url":"https://api.github.com/repos/OrchardCMS/Orchard2/hooks","issue_events_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/events{/number}","events_url":"https://api.github.com/repos/OrchardCMS/Orchard2/events","assignees_url":"https://api.github.com/repos/OrchardCMS/Orchard2/assignees{/user}","branches_url":"https://api.github.com/repos/OrchardCMS/Orchard2/branches{/branch}","tags_url":"https://api.github.com/repos/OrchardCMS/Orchard2/tags","blobs_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/refs{/sha}","trees_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OrchardCMS/Orchard2/statuses/{sha}","languages_url":"https://api.github.com/repos/OrchardCMS/Orchard2/languages","stargazers_url":"https://api.github.com/repos/OrchardCMS/Orchard2/stargazers","contributors_url":"https://api.github.com/repos/OrchardCMS/Orchard2/contributors","subscribers_url":"https://api.github.com/repos/OrchardCMS/Orchard2/subscribers","subscription_url":"https://api.github.com/repos/OrchardCMS/Orchard2/subscription","commits_url":"https://api.github.com/repos/OrchardCMS/Orchard2/commits{/sha}","git_commits_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/commits{/sha}","comments_url":"https://api.github.com/repos/OrchardCMS/Orchard2/comments{/number}","issue_comment_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/comments{/number}","contents_url":"https://api.github.com/repos/OrchardCMS/Orchard2/contents/{+path}","compare_url":"https://api.github.com/repos/OrchardCMS/Orchard2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OrchardCMS/Orchard2/merges","archive_url":"https://api.github.com/repos/OrchardCMS/Orchard2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OrchardCMS/Orchard2/downloads","issues_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues{/number}","pulls_url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls{/number}","milestones_url":"https://api.github.com/repos/OrchardCMS/Orchard2/milestones{/number}","notifications_url":"https://api.github.com/repos/OrchardCMS/Orchard2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OrchardCMS/Orchard2/labels{/name}","releases_url":"https://api.github.com/repos/OrchardCMS/Orchard2/releases{/id}","deployments_url":"https://api.github.com/repos/OrchardCMS/Orchard2/deployments","created_at":"2014-11-19T22:29:26Z","updated_at":"2016-12-08T14:37:34Z","pushed_at":"2016-12-08T14:29:12Z","git_url":"git://github.com/OrchardCMS/Orchard2.git","ssh_url":"git@github.com:OrchardCMS/Orchard2.git","clone_url":"https://github.com/OrchardCMS/Orchard2.git","svn_url":"https://github.com/OrchardCMS/Orchard2","homepage":null,"size":11626,"stargazers_count":599,"watchers_count":599,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":231,"mirror_url":null,"open_issues_count":113,"forks":231,"open_issues":113,"watchers":599,"default_branch":"master"}},"base":{"label":"OrchardCMS:master","ref":"master","sha":"8e35a191239e15ef2db4819c0bef60e402f926f0","user":{"login":"OrchardCMS","id":1159247,"avatar_url":"https://avatars.githubusercontent.com/u/1159247?v=3","gravatar_id":"","url":"https://api.github.com/users/OrchardCMS","html_url":"https://github.com/OrchardCMS","followers_url":"https://api.github.com/users/OrchardCMS/followers","following_url":"https://api.github.com/users/OrchardCMS/following{/other_user}","gists_url":"https://api.github.com/users/OrchardCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/OrchardCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrchardCMS/subscriptions","organizations_url":"https://api.github.com/users/OrchardCMS/orgs","repos_url":"https://api.github.com/users/OrchardCMS/repos","events_url":"https://api.github.com/users/OrchardCMS/events{/privacy}","received_events_url":"https://api.github.com/users/OrchardCMS/received_events","type":"Organization","site_admin":false},"repo":{"id":26884725,"name":"Orchard2","full_name":"OrchardCMS/Orchard2","owner":{"login":"OrchardCMS","id":1159247,"avatar_url":"https://avatars.githubusercontent.com/u/1159247?v=3","gravatar_id":"","url":"https://api.github.com/users/OrchardCMS","html_url":"https://github.com/OrchardCMS","followers_url":"https://api.github.com/users/OrchardCMS/followers","following_url":"https://api.github.com/users/OrchardCMS/following{/other_user}","gists_url":"https://api.github.com/users/OrchardCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/OrchardCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OrchardCMS/subscriptions","organizations_url":"https://api.github.com/users/OrchardCMS/orgs","repos_url":"https://api.github.com/users/OrchardCMS/repos","events_url":"https://api.github.com/users/OrchardCMS/events{/privacy}","received_events_url":"https://api.github.com/users/OrchardCMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OrchardCMS/Orchard2","description":"Orchard vNext","fork":false,"url":"https://api.github.com/repos/OrchardCMS/Orchard2","forks_url":"https://api.github.com/repos/OrchardCMS/Orchard2/forks","keys_url":"https://api.github.com/repos/OrchardCMS/Orchard2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OrchardCMS/Orchard2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OrchardCMS/Orchard2/teams","hooks_url":"https://api.github.com/repos/OrchardCMS/Orchard2/hooks","issue_events_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/events{/number}","events_url":"https://api.github.com/repos/OrchardCMS/Orchard2/events","assignees_url":"https://api.github.com/repos/OrchardCMS/Orchard2/assignees{/user}","branches_url":"https://api.github.com/repos/OrchardCMS/Orchard2/branches{/branch}","tags_url":"https://api.github.com/repos/OrchardCMS/Orchard2/tags","blobs_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/refs{/sha}","trees_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OrchardCMS/Orchard2/statuses/{sha}","languages_url":"https://api.github.com/repos/OrchardCMS/Orchard2/languages","stargazers_url":"https://api.github.com/repos/OrchardCMS/Orchard2/stargazers","contributors_url":"https://api.github.com/repos/OrchardCMS/Orchard2/contributors","subscribers_url":"https://api.github.com/repos/OrchardCMS/Orchard2/subscribers","subscription_url":"https://api.github.com/repos/OrchardCMS/Orchard2/subscription","commits_url":"https://api.github.com/repos/OrchardCMS/Orchard2/commits{/sha}","git_commits_url":"https://api.github.com/repos/OrchardCMS/Orchard2/git/commits{/sha}","comments_url":"https://api.github.com/repos/OrchardCMS/Orchard2/comments{/number}","issue_comment_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/comments{/number}","contents_url":"https://api.github.com/repos/OrchardCMS/Orchard2/contents/{+path}","compare_url":"https://api.github.com/repos/OrchardCMS/Orchard2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OrchardCMS/Orchard2/merges","archive_url":"https://api.github.com/repos/OrchardCMS/Orchard2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OrchardCMS/Orchard2/downloads","issues_url":"https://api.github.com/repos/OrchardCMS/Orchard2/issues{/number}","pulls_url":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls{/number}","milestones_url":"https://api.github.com/repos/OrchardCMS/Orchard2/milestones{/number}","notifications_url":"https://api.github.com/repos/OrchardCMS/Orchard2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OrchardCMS/Orchard2/labels{/name}","releases_url":"https://api.github.com/repos/OrchardCMS/Orchard2/releases{/id}","deployments_url":"https://api.github.com/repos/OrchardCMS/Orchard2/deployments","created_at":"2014-11-19T22:29:26Z","updated_at":"2016-12-08T14:37:34Z","pushed_at":"2016-12-08T14:29:12Z","git_url":"git://github.com/OrchardCMS/Orchard2.git","ssh_url":"git@github.com:OrchardCMS/Orchard2.git","clone_url":"https://github.com/OrchardCMS/Orchard2.git","svn_url":"https://github.com/OrchardCMS/Orchard2","homepage":null,"size":11626,"stargazers_count":599,"watchers_count":599,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":231,"mirror_url":null,"open_issues_count":113,"forks":231,"open_issues":113,"watchers":599,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394"},"html":{"href":"https://github.com/OrchardCMS/Orchard2/pull/394"},"issue":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/394"},"comments":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/issues/394/comments"},"review_comments":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394/comments"},"review_comment":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/pulls/394/commits"},"statuses":{"href":"https://api.github.com/repos/OrchardCMS/Orchard2/statuses/f0d7b7d26911b83915adce5893a32265535d9b8d"}}}}
{"actor":{"display_login":"sebastienros"}}