public async Task <ActionResult> Login(LoginViewModel model) { if (model.Username == null || model.Password == null) { ClearAndAddModelError("Please enter username and password."); return(View(model)); } var response = await _authenticationClient.GetHttpResponse(model); if (response.IsSuccessStatusCode) { var tokenResponse = await _authenticationClient.GetTokenFromHttpResponse(response); SetToken(tokenResponse.AccessToken); return(RedirectToAction("AllMeasurements", "Measurements")); } ModelState.Clear(); ModelState.AddModelError("", "The username or password is incorrect"); return(View(model)); }