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 })); }
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); } }
private CustomPrincipal(ICustomIdentity identity) { this.Identity = identity; }
public CustomPrincipal(ICustomIdentity customIdentity, string[] roles) : base(customIdentity, roles) { Identity = customIdentity; }
public _LayoutViewModel(ICustomIdentity customIdentity) { CustomIdentity = customIdentity; }
public QuestionViewModel(ICustomIdentity customIdentity) : base(customIdentity) { }
public IndexViewModel(ICustomIdentity customIdentity) : base(customIdentity) { }
public CustomPrincipal(ICustomIdentity identity) { this.Identity = identity; }