public async Task <IActionResult> Post([FromBody] UserViewModel theUser) { if (ModelState.IsValid) { var password = theUser.Password; var newUser = Mapper.Map <User>(theUser); //Save to the database try { await _repository.AddUser(newUser, password); var user = await _userManager.FindByEmailAsync(newUser.Email); if (user != null) { var _signInResult = await _signInManager .PasswordSignInAsync(user, theUser.Password, true, false); } else { ModelState.AddModelError("", "Ez az email cím nem szerepel az adatbáziusnkban."); } return(Ok()); } catch (Exception ex) { return(BadRequest(ex + "Error occured")); } } return(BadRequest("failed to save")); }