Пример #1
0
        public async Task <IdentityUser> RegisterNewUserAsync(RegisterReq newModel)
        {
            try
            {
                var newUser = new IdentityUser {
                    UserName = newModel.UserName, Email = newModel.UserName
                };

                //Remove and activate email confirmation in RegisterController once in production
                newUser.EmailConfirmed = true;

                await _userManager.CreateAsync(newUser);

                await _userManager.AddPasswordAsync(newUser, newModel.PassWord);

                await _profileDataService.CreateNewProfileAsync((await _userManager.FindByNameAsync(newUser.UserName)).Id);

                return(await _userManager.FindByNameAsync(newModel.UserName));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }