<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Cats.Models.ViewModels;
using Cats.Services.Security;

namespace Cats.Controllers
{
    [Authorize]
    public class AccountController : Controller
    {
        private IUserAccountService service;

        public AccountController(IUserAccountService userAccountService)
        {
            service = userAccountService;
        }

        [AllowAnonymous]
        public ActionResult Login()
        {
            ViewBag.HasError = false;
            return View();
        }

        [HttpPost]
        [AllowAnonymous]
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            // Check if the supplied credentials are correct.
            try
            {
                if (service.Authenticate(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    string[] authorization = service.GetUserPermissions(service.GetUserInfo(model.UserName).UserAccountId, "Administrator", "Manage User Account");
                    return RedirectToLocal(returnUrl);<commit_msg>Move user authentication and authorization to a separate db<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Cats.Models.ViewModels;
using Cats.Services.Security;

namespace Cats.Controllers
{
    [Authorize]
    public class AccountController : Controller
    {
        private IUserAccountService service;

        public AccountController(IUserAccountService userAccountService)
        {
            service = userAccountService;
        }

        [AllowAnonymous]
        public ActionResult Login()
        {
            ViewBag.HasError = false;
            return View();
        }

        [HttpPost]
        [AllowAnonymous]
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            // Check if the supplied credentials are correct.
            try
            {
                if (service.Authenticate(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    // TODO: Review user permission code
                    //string[] authorization = service.GetUserPermissions(service.GetUserInfo(model.UserName).UserAccountId, "Administrator", "Manage User Account");
                    return RedirectToLocal(returnUrl);
{'fraction_non_alphanumeric': 0.07622298065984073, 'fraction_numerical': 0.0, 'mean_word_length': 2.2608158220024723, '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': '4805943', 'n_tokens_mistral': 651, 'n_tokens_neox': 628, 'n_words': 150}