Exemplo n.º 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);
        }
        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
            }));
        }
Exemplo n.º 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();
        }
        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);
            }
        }
Exemplo n.º 5
0
 private CustomPrincipal(ICustomIdentity identity)
 {
     this.Identity = identity;
 }
 public CustomPrincipal(ICustomIdentity customIdentity, string[] roles)
     : base(customIdentity, roles)
 {
     Identity = customIdentity;
 }
Exemplo n.º 7
0
 public _LayoutViewModel(ICustomIdentity customIdentity)
 {
     CustomIdentity = customIdentity;
 }
Exemplo n.º 8
0
 public QuestionViewModel(ICustomIdentity customIdentity) : base(customIdentity)
 {
 }
Exemplo n.º 9
0
 private CustomPrincipal(ICustomIdentity identity)
 {
     this.Identity = identity;
 }
 public CustomPrincipal(ICustomIdentity customIdentity, string[] roles)
     : base(customIdentity, roles)
 {
     Identity = customIdentity;
 }
Exemplo n.º 11
0
 public IndexViewModel(ICustomIdentity customIdentity) : base(customIdentity)
 {
 }
Exemplo n.º 12
0
 public IndexViewModel(ICustomIdentity customIdentity)
     : base(customIdentity)
 {
 }
Exemplo n.º 13
0
 public CustomPrincipal(ICustomIdentity identity)
 {
     this.Identity = identity;
 }
Exemplo n.º 14
0
 public QuestionViewModel(ICustomIdentity customIdentity)
     : base(customIdentity)
 {
 }
 public _LayoutViewModel(ICustomIdentity customIdentity)
 {
     CustomIdentity = customIdentity;
 }