コード例 #1
0
        public static bool Login(string cookieString)
        {
            ICustomIdentity identity = CustomIdentity.FromJson(cookieString);

            if (identity.IsAuthenticated)
            {
                HttpContext.Current.User = new CustomPrincipal(identity);
            }
            return(identity.IsAuthenticated);
        }
コード例 #2
0
        public IResult Process(FakeHttpContext context, System.Runtime.InteropServices.Expando.IExpando expando)
        {
            bool            isRegister = expando.GetString("IsRegister") == "checked";
            ICustomIdentity identity   = ServiceLocator.Instance.GetService <ICustomIdentity>();

            identity.MockUser.IsActiveMail = isRegister;
            ServerApiInvoker.PostEmailRegisterStatue(identity.MockUser.Id, isRegister);
            return(new MatchHandler().HandleRequest(new UrlRequest()
            {
                Url = context.PageUrl, HttpContext = context
            }));
        }
コード例 #3
0
        void accountitem_Click(object sender, EventArgs e)
        {
            if (accLastSelect != null)
            {
                accLastSelect.Image = null;
            }
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            accLastSelect = item;
            item.Select();
            item.Image = Resources.selection;
            MockUser        mockUser = item.Tag as MockUser;
            ICustomIdentity identity = ServiceLocator.Instance.GetService <ICustomIdentity>();

            identity.MockUser = mockUser;

            ServerApiInvoker.Shift_MockUserAccount(mockUser.Id);

            ToolStripDropDownButton dd = Items["shiftAccount"] as ToolStripDropDownButton;

            dd.Text = item.Text;
            Home();
        }
コード例 #4
0
        public static void SetAuthCookie(ICustomIdentity customIdentity)
        {
            var cookie = FormsAuthentication.GetAuthCookie(customIdentity.Name, false);
            var ticket = FormsAuthentication.Decrypt(cookie.Value);

            StringBuilder userDataBuilder = new StringBuilder();
            foreach (var x in customIdentity.Claims)
            {
                userDataBuilder.AppendFormat("{0}'{1}'\r", x.Key, x.Value.Replace("'","''"));
            }
            ticket = new FormsAuthenticationTicket(ticket.Version,
                                                   ticket.Name,
                                                   ticket.IssueDate,
                                                   ticket.Expiration,
                                                   ticket.IsPersistent,
                                                   userDataBuilder.ToString(),
                                                   ticket.CookiePath);

            string encrypetedTicket = FormsAuthentication.Encrypt(ticket);
            //Set the authentication cookie and go back to the home page
            //HttpContext.Current.Response.Cookies.Set(cookie);

            if (!FormsAuthentication.CookiesSupported)
            {

                //This method works for both cookie and cookieless
                FormsAuthentication.SetAuthCookie(encrypetedTicket, false);

            }
            else
            {

                //This way only work for cookie
                cookie.Value = encrypetedTicket;
                HttpContext.Current.Response.Cookies.Set(cookie);
            }
        }
コード例 #5
0
 private CustomPrincipal(ICustomIdentity identity)
 {
     this.Identity = identity;
 }
コード例 #6
0
 public CustomPrincipal(ICustomIdentity customIdentity, string[] roles)
     : base(customIdentity, roles)
 {
     Identity = customIdentity;
 }
コード例 #7
0
 public _LayoutViewModel(ICustomIdentity customIdentity)
 {
     CustomIdentity = customIdentity;
 }
コード例 #8
0
 public QuestionViewModel(ICustomIdentity customIdentity) : base(customIdentity)
 {
 }
コード例 #9
0
ファイル: CustomPrincipal.cs プロジェクト: Mousum/erp_asp
 private CustomPrincipal(ICustomIdentity identity)
 {
     this.Identity = identity;
 }
コード例 #10
0
 public CustomPrincipal(ICustomIdentity customIdentity, string[] roles)
     : base(customIdentity, roles)
 {
     Identity = customIdentity;
 }
コード例 #11
0
 public IndexViewModel(ICustomIdentity customIdentity) : base(customIdentity)
 {
 }
コード例 #12
0
 public IndexViewModel(ICustomIdentity customIdentity)
     : base(customIdentity)
 {
 }
コード例 #13
0
ファイル: CustomPrincipal.cs プロジェクト: fengzijun/Beauty
 public CustomPrincipal(ICustomIdentity identity)
 {
     this.Identity = identity;
 }
コード例 #14
0
 public QuestionViewModel(ICustomIdentity customIdentity)
     : base(customIdentity)
 {
 }
コード例 #15
0
 public _LayoutViewModel(ICustomIdentity customIdentity)
 {
     CustomIdentity = customIdentity;
 }