
using PageAdmin.BLL;
using PageAdmin.Common;
using PageAdmin.Web.Filter;
using PageAdmin.Utils;
using PageAdmin.Web.Areas.Member.Controllers.Login;
using System.Web.Mvc;

namespace PageAdmin.Web.Areas.Member.Controllers
{
    [AllowAnonymous]
    public class LoginController : BaseController
    {
        [Config]
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }

        [Validate]
        [CheckMemberLock]
        [ValidateAntiForgeryToken]
        [HttpPost]
        [AjaxOnly]
        public JsonResult Index(FormCollection form)
        {
            MvcControllerContext mvcContext = new MvcControllerContext();
            mvcContext.Data = form;
            TipsInfo tipsInfo = mvcContext.TipsInfo;

            if (tipsInfo.State == 0)
            {
                return Json(tipsInfo);
            }
            MemberLoginBLL BLL = new MemberLoginBLL();
            tipsInfo = BLL.Login(mvcContext);
            if (tipsInfo.State == 1)
            {
                VerificationCodeBLL verificationCodeBLL = new VerificationCodeBLL();
                verificationCodeBLL.Clear();
                SmsCodeBLL smsCodeBLL = new SmsCodeBLL();
                smsCodeBLL.Clear();
                EmailCodeBLL emailCodeBLL = new EmailCodeBLL();
                emailCodeBLL.Clear();
            }
            return Json(tipsInfo);
        }




    }
}
