Esempio n. 1
0
        public async Task <IActionResult> Register(Registration registration)
        {
            if (ModelState.IsValid)
            {
                AppUser newUser = new AppUser
                {
                    UserName = registration.Username
                };

                IdentityResult createResult = await _userManager.CreateAsync(newUser, registration.Password);

                if (createResult.Succeeded)
                {
                    await _userImageService.StoreImageForUserId(newUser.Id);

                    await _signInManager.SignInAsync(newUser, isPersistent : true);

                    return(Ok());
                }

                ModelState.AddIdentityErrors(createResult);
            }

            return(BadRequest(ModelState));
        }