public ActionResult Login(string username, string errorMessage = "")
        {
            var viewModel = new AccountLoginViewModel
            {
                Username = username,
                ErrorMessage = errorMessage
            };

            return View(viewModel);
        }
 public async Task<ActionResult> Login(AccountLoginViewModel viewModel)
 {
     var loginResult = await this.apiClient.LogOn(new Credentials { Username = viewModel.Username, Password = viewModel.Password });
     if (loginResult.ResultCode == ResultCode.Ok)
     {
         // Save Auth token to a cookie
         var authCookie = this.ControllerContext.HttpContext.Request.Cookies["KTS-AuthToken"];
         if (authCookie == null)
         {
             authCookie = new HttpCookie("KTS-AuthToken");
         }
         authCookie.Value = loginResult.Data.Token;
         authCookie.Expires = DateTime.UtcNow.AddDays(30);
         this.ControllerContext.HttpContext.Response.Cookies.Set(authCookie);
         return RedirectToAction("Index", "Home");
     }
     else
     {
         viewModel.ErrorMessage = "Login failed.";
         viewModel.Password = String.Empty;
         return RedirectToAction("Login", "Account", viewModel);
     }
 }