<commit_before>﻿using System;
using System.Web.Mvc;
using Agiil.Auth;
using Agiil.Domain;
using Agiil.Domain.Auth;
using Agiil.Web.Models.Auth;
using Agiil.Web.Services.Auth;

namespace Agiil.Web.Controllers
{
  [AllowAnonymous]
  public class LoginController : Controller
  {
    #region constants

    public static readonly string
      LoginResultKey = "LoginResult",
      CredentialsKey = "Credentials";

    #endregion

    #region fields

    readonly LoginRequestCreator loginRequestCreator;
    readonly ILoginLogoutManager loginLogoutManager;
    readonly IValidatesRedirectUrls redirectUriValidator;

    #endregion

    #region controller actions

    [HttpGet]
    public ActionResult Index(string returnUrl)
    {
      var model = GetLoginModel();
      model.ReturnUrl = returnUrl;
      return View(model);
    }

    [HttpGet]
    public ActionResult LoggedOut()
    {
      return View();
    }

    [HttpPost]
    public ActionResult Login(Models.Auth.LoginCredentials credentials)
    {
      var loginRequest = loginRequestCreator(credentials.Username, credentials.Password, Request?.UserHostAddress);
      var result = loginLogoutManager.AttemptLogin(loginRequest);

      TempData.Clear();

      TempData.Add(LoginResultKey, result);<commit_msg>Unrelated - Fix issue with styling of logged-out page<commit_after>﻿using System;
using System.Web.Mvc;
using Agiil.Auth;
using Agiil.Domain;
using Agiil.Domain.Auth;
using Agiil.Web.Models.Auth;
using Agiil.Web.Services.Auth;

namespace Agiil.Web.Controllers
{
  [AllowAnonymous]
  public class LoginController : Controller
  {
    #region constants

    public static readonly string
      LoginResultKey = "LoginResult",
      CredentialsKey = "Credentials";

    #endregion

    #region fields

    readonly LoginRequestCreator loginRequestCreator;
    readonly ILoginLogoutManager loginLogoutManager;
    readonly IValidatesRedirectUrls redirectUriValidator;

    #endregion

    #region controller actions

    [HttpGet]
    public ActionResult Index(string returnUrl)
    {
      var model = GetLoginModel();
      model.ReturnUrl = returnUrl;
      return View(model);
    }

    [HttpGet]
    public ActionResult LoggedOut()
    {
      return View(new Models.PageModel());
    }

    [HttpPost]
    public ActionResult Login(Models.Auth.LoginCredentials credentials)
    {
      var loginRequest = loginRequestCreator(credentials.Username, credentials.Password, Request?.UserHostAddress);
      var result = loginLogoutManager.AttemptLogin(loginRequest);

      TempData.Clear();

      TempData.Add(LoginResultKey, result);
{'fraction_non_alphanumeric': 0.08019953952417498, 'fraction_numerical': 0.0, 'mean_word_length': 3.630550621669627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6425520', 'n_tokens_mistral': 744, 'n_tokens_neox': 727, 'n_words': 169}