public RedirectResult Logout()
        {
            HttpContext.GetOwinContext().Authentication.SignOut();

            string getLoginFlag = string.Empty;
            var    getCookie    = Request.Cookies["user_login"];

            getLoginFlag = getCookie == null ? "Y" :
                           EncryptString.desDecryptBase64(Server.UrlDecode(getCookie.Value)); //Value:N

            Session.Remove("IsAuthorized");                                                   //ckfinder用
            removeCookie("user_id");
            removeCookie("user_name");
            removeCookie("user_login");
            SiteMaps.ReleaseSiteMap();

            if (getLoginFlag == "Y")
            {
                return(Redirect("~"));
            }
            else
            {
                return(Redirect("~/_SysAdm?t=" + DateTime.Now.Ticks));
            }
        }
Beispiel #2
0
        public RedirectResult Logout()
        {
            HttpContext.GetOwinContext().Authentication.SignOut();

            string getLoginFlag = string.Empty;
            var    getCookie    = Request.Cookies["user_login"];

            getLoginFlag = getCookie == null ? "Y" :
                           EncryptString.desDecryptBase64(Server.UrlDecode(getCookie.Value)); //Value:N

            removeCookie("user_id");
            removeCookie("user_name");
            removeCookie(CommWebSetup.WebCookiesId + ".member_id");
            removeCookie(CommWebSetup.WebCookiesId + ".member_name");
            removeCookie("user_login");

            ObjectCache cache = MemoryCache.Default;

            cache.Clear();

            //SiteMaps.ReleaseSiteMap();

            if (getLoginFlag == "Y")
            {
                return(Redirect("~"));
            }
            else
            {
                return(Redirect("~/_SysAdm?t=" + DateTime.Now.Ticks));
            }
        }
Beispiel #3
0
        protected void upCheckCode(string code)
        {
            ResultInfo r = new ResultInfo();

            using (TransactionScope tx = new TransactionScope())
            {
                using (var db = getDB0())
                {
                    try
                    {
                        string dec_code = EncryptString.desDecryptBase64(code);//解密
                        var    item     = db.TimeLinessCode.Find(dec_code);

                        item.is_use = true;

                        db.SaveChanges();
                        tx.Complete();
                        r.result = true;
                    }
                    catch (Exception ex)
                    {
                        r.result  = false;
                        r.message = ex.ToString();
                    }
                }
            }
        }
Beispiel #4
0
        protected bool checkCode(string code)
        {
            using (var db0 = getDB0())
            {
                string dec_code = EncryptString.desDecryptBase64(code);//解密
                var    item     = db0.TimeLinessCode.FirstOrDefault(x => x.Id == dec_code & !x.is_use);
                bool   res      = item == null ? false : true;

                return(res);
            }
        }
        public ActionResult ChangePassWord(string mail, string code)
        {
            using (var db0 = getDB0())
            {
                bool   check    = false;
                string dec_code = string.Empty;
                try
                {
                    dec_code = EncryptString.desDecryptBase64(code);
                }
                catch (Exception ex)
                {
                    string test = ex.ToString();
                }


                var item = db0.TimeLinessCode.FirstOrDefault(x => x.Id == dec_code);

                if (mail == null || code == null || item == null)
                {
                    check = true;
                }
                else if (!db0.Customer.Any(x => x.email == mail))
                {
                    check = true;
                }
                else if (DateTime.Now > item.i_ExpiryDateTime)
                {//超過有效期限
                    check = true;
                }
                else if (item.is_use)
                {//已使用過
                    check = true;
                }


                if (check)
                {
                    return(Redirect("~/User/LinkFail"));
                }
            }
            return(View());
        }
Beispiel #6
0
        protected override void Initialize(System.Web.Http.Controllers.HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);

            var aspnet_user_id = User.Identity.GetUserId();

            #region 判斷是管理端、用戶端登入
            var getLoginUserFlag = controllerContext.Request.Headers.GetCookies("user_login").SingleOrDefault();
            LoginUserFlag = getLoginUserFlag == null ? "" :
                            EncryptString.desDecryptBase64(getLoginUserFlag["user_login"].Value);
            #endregion
            if (aspnet_user_id != null)
            {
                ApplicationUser aspnet_user = UserManager.FindById(aspnet_user_id);
                UserId       = aspnet_user.Id;
                departmentId = aspnet_user.department_id;
                UserRoles    = aspnet_user.Roles.Select(x => x.RoleId);
            }
        }
Beispiel #7
0
        protected override void Initialize(System.Web.Http.Controllers.HttpControllerContext controllerContext)
        {
            base.Initialize(controllerContext);

            var identity = User.Identity; //一定要有值 無值為系統出問題

            #region 判斷是管理端、用戶端登入
            //var getLoginUserFlag = controllerContext.Request.Headers.GetCookies(CommWebSetup.LoginType).SingleOrDefault();
            //LoginUserFlag = getLoginUserFlag == null ? "" :
            //    EncryptString.desDecryptBase64(getLoginUserFlag[CommWebSetup.LoginType].Value);
            #endregion
            if (identity.IsAuthenticated)
            {
                var FormsIdentity = (System.Web.Security.FormsIdentity)User.Identity;                                 //一定要有值 無值為系統出問題
                var id            = EncryptString.desDecryptBase64(HttpUtility.UrlDecode(FormsIdentity.Ticket.Name)); //userid
                //取得權限
                var      roles  = FormsIdentity.Ticket.UserData.Split(',');
                var      roleId = roles.FirstOrDefault();
                string[] r_s    = new string[] { "Admins", "Managers" };
                if (r_s.Contains(roleId))
                {//管理端登入
                    LoginUserFlag = "N";
                    aspUserId     = id;
                    ApplicationUser aspnet_user = UserManager.FindById(aspUserId);
                    UserId       = aspnet_user.Id;
                    departmentId = aspnet_user.department_id;
                    UserRoles    = aspnet_user.Roles.Select(x => x.RoleId);
                }
                else
                {
                    LoginUserFlag = "Y";
                    UserId        = id;
                    //取得權限
                    UserRoles = FormsIdentity.Ticket.UserData.Split(',');
                }
            }
        }