Ejemplo n.º 1
0
        public ActionResult Login()
        {
            //if (IsAuthorised("154211"))
            //{
            //    return Redirect("~/" + SessionHelper.DefaultPage);
            //}

            //SessionHelper.UserName = "******";
            //SessionHelper.UserId = 3;
            //SessionHelper.UnitId = 1;
            //SessionHelper.DateFormat = "dd MMM, yyyy";
            //return Redirect("~/Main");


            var encriptData = string.Empty;

            if (Request.QueryString[SsoUtility.SsoToken] != null)
            {
                encriptData = HttpUtility.HtmlDecode(Request.QueryString[SsoUtility.SsoToken]);


                //Process for normal authentication
                var objSsoManager = new SSOManager();
                var objSso        = objSsoManager.GetSSO(encriptData);

                //SMSC.Models.SMSCContext _contex = new Models.SMSCContext();
                if (objSso.authenticated == true)
                {
                    userLoginLogService.Add(new UserLoginLog
                    {
                        PIN         = objSso.name
                        , Name      = objSso.fullname
                        , LoginTime = DateTime.Now
                    });

                    unitOfWork.Commit();
                    SessionHelper.IsGuest = false;

                    if (IsAuthorised(objSso.name))
                    {
                        return(Redirect("~/" + SessionHelper.DefaultPage));
                    }
                    else
                    {
                        SessionHelper.UserName = objSso.fullname;
                        SessionHelper.UserId   = 0;
                        SessionHelper.UnitId   = 1;
                        //SessionHelper.DateFormat = "dd MMM, yyyy";
                        return(Redirect("~/Main"));
                    }
                }
                else if (objSso.name != null)
                {
                    ModelState.AddModelError("", "");
                }
            }

            return(View("Index"));
        }