Ejemplo n.º 1
0
        public ActionResult Login(AccountLoginModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            string          resultStr = "";
            AccountDbModels act       = new AccountDbModels();
            EsmUser         model     = new EsmUser();

            model = act.loginChk(viewModel);                //로그인 체크



            if (model == null)                          //아이디 페스워드 체크
            {
                resultStr         = "이메일 또는 비밀번호를 확인해 주시기 바랍니다.";
                ViewBag.PublicMsg = resultStr;
                return(View(viewModel));
            }

            if (model.STATUS == 0)              //사용 여부 체크
            {
                resultStr         = "사용이 정지된 계정입니다.";
                ViewBag.PublicMsg = resultStr;
                return(View(viewModel));
            }


            FormsAuthentication.SetAuthCookie(viewModel.Email, false);

            Session["MANAGE_NO"]           = model.SEQNO;
            Session["MANAGE_GRADE"]        = model.GROUP_ID;
            Session["CURRENT_LOGIN_EMAIL"] = model.EMAIL;

            //로그인 기록 데이터 세팅
            CommLoginLog clh = new CommLoginLog();

            clh.EMAIL  = viewModel.Email;
            clh.IPADDR = Request.UserHostAddress;

            act.loginHis(clh);                //로그인 로그 기록

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Login(AccountLoginModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            string  resultStr = "";
            EseUser model     = new EseUser();

            model = act.loginChk(viewModel);                //로그인 체크



            if (model == null)                  //아이디 페스워드 체크
            {
                resultStr         = "이메일 또는 비밀번호를 확인해 주시기 바랍니다.";
                ViewBag.PublicMsg = resultStr;
                return(View(viewModel));
            }

            if (model.chkSTATUS == 1)              //사용 여부 체크
            {
                resultStr         = "사용이 정지된 계정입니다.";
                ViewBag.PublicMsg = resultStr;
                return(View(viewModel));
            }

            if (model.STATUS == 1)              //사용 여부 체크
            {
                resultStr         = "사용이 정지된 ESE 계정입니다.";
                ViewBag.PublicMsg = resultStr;
                return(View(viewModel));
            }

            if (model.STATUS == 2)              //사용 여부 체크
            {
                //resultStr = "[문구 수정 필요]승인되지 않은 사용자 입니다. 기본정보를 입력해주시면 빠른시일에 승인 처리 해드리겠습니다.";
                //ViewBag.PublicMsg = resultStr;
            }

            FormsAuthentication.SetAuthCookie(viewModel.Email, false);

            Session["MANAGE_NO"]           = model.SEQNO;
            Session["MANAGE_GRADE"]        = model.GROUP_ID;
            Session["CURRENT_LOGIN_EMAIL"] = model.EMAIL;
            Session["EST_CODE"]            = model.EST_CODE;
            Session["ESE_CODE"]            = model.ESE_CODE;
            Session["STATUS"] = model.STATUS;

            //로그인 유지 체크 시 쿠키 설정
            if (viewModel.RememberMe)
            {
                Response.Cookies["CHK_LOGIN_REMEMBER"].Value  = "CHK_LOGIN_REMEMBER";
                Response.Cookies["MANAGE_NO"].Value           = model.SEQNO.ToString();
                Response.Cookies["MANAGE_GRADE"].Value        = model.GROUP_ID.ToString();
                Response.Cookies["CURRENT_LOGIN_EMAIL"].Value = model.EMAIL;
                Response.Cookies["EST_CODE"].Value            = model.EST_CODE;
                Response.Cookies["ESE_CODE"].Value            = model.ESE_CODE;
                Response.Cookies["STATUS"].Value = model.STATUS.ToString();
            }
            else
            {
                //로그인 유지 체크 헤제 시 쿠키 삭제
                if (Request.Cookies["CHK_LOGIN_REMEMBER"] != null)
                {
                    Response.Cookies["CHK_LOGIN_REMEMBER"].Expires = DateTime.Now.AddDays(-1);
                }
                if (Request.Cookies["MANAGE_NO"] != null)
                {
                    Response.Cookies["MANAGE_NO"].Expires = DateTime.Now.AddDays(-1);
                }
                if (Request.Cookies["MANAGE_GRADE"] != null)
                {
                    Response.Cookies["MANAGE_GRADE"].Expires = DateTime.Now.AddDays(-1);
                }
                if (Request.Cookies["CURRENT_LOGIN_EMAIL"] != null)
                {
                    Response.Cookies["CURRENT_LOGIN_EMAIL"].Expires = DateTime.Now.AddDays(-1);
                }
                if (Request.Cookies["EST_CODE"] != null)
                {
                    Response.Cookies["EST_CODE"].Expires = DateTime.Now.AddDays(-1);
                }
                if (Request.Cookies["ESE_CODE"] != null)
                {
                    Response.Cookies["ESE_CODE"].Expires = DateTime.Now.AddDays(-1);
                }
                if (Request.Cookies["STATUS"] != null)
                {
                    Response.Cookies["STATUS"].Expires = DateTime.Now.AddDays(-1);
                }
            }



            //로그인 기록 데이터 세팅
            CommLoginLog clh = new CommLoginLog();

            clh.ESE_CODE = model.ESE_CODE;
            clh.EMAIL    = viewModel.Email;
            clh.IPADDR   = Request.UserHostAddress;

            act.loginHis(clh);                //로그인 로그 기록

            return(RedirectToLocal(viewModel.ReturnUrl));
            //return RedirectToAction("Index", "Home");
        }