public async Task <IActionResult> Post(LoginModel login)
        {
            var userCreation = await userManager.CreateAsync(new User { UserName = login.Email, Email = login.Email }, login.Password);

            if (userCreation.Succeeded)
            {
                var user = await repository.GetUserByEmail(login.Email);

                return(Ok(mapper.Map <User, UserModel>(user)));
            }
            StringBuilder jsonErrors = new StringBuilder();

            foreach (var error in userCreation.Errors)
            {
                if (jsonErrors.Length != 0)
                {
                    jsonErrors.Append(",");
                }
                jsonErrors.Append($"\"{error.Description}\"");
            }

            return(BadRequest($"{{\"errors\":[{jsonErrors.ToString()}]}}"));
        }
        private async Task <UserModel> Authenticate(LoginModel login)
        {
            var result = await signInManager.PasswordSignInAsync(login.Email, login.Password, true, lockoutOnFailure : false);

            if (result.Succeeded)
            {
                var user = await repository.GetUserByEmail(login.Email);

                if (user != null)
                {
                    return(mapper.Map <User, UserModel>(user));
                }
            }
            return(null);
        }