public async Task <IActionResult> Login([FromBody] RegisterCredentialsModel creds) { var user = await _dbContext.AppUsers.FirstOrDefaultAsync(x => x.Email == creds.Email); if (user == null) { return(Json(new BaseResponseModel() { Success = false, Error = "Lietotājs nav atrasts!" })); } if (user.PasswordHash != AuthUtils.GetHashString(creds.Password)) { return(Json(new BaseResponseModel() { Success = false, Error = "Nepareiza parole!" })); } ; return(Json(new LoginResponseModel() { Token = AuthUtils.GenerateJSONWebToken(_configuration["Jwt:Key"], user.Id), Email = user.Email })); }