Пример #1
0
        public static void RegistrarLogin(string cpf, Laboris.Cosan.Service.Omnion.Login usuarioOmnion, string senha, HttpResponse Response)
        {
            HttpCookie authCookie = FormsAuthentication.GetAuthCookie(cpf, false);

            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
            FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, usuarioOmnion.Nome);

            authCookie.Value = FormsAuthentication.Encrypt(newTicket);
            authCookie.Path = FormsAuthentication.FormsCookiePath;

            Response.Cookies.Add(authCookie);

            IPrincipal p = new GenericPrincipal(new FormsIdentity(newTicket), null);

            UsuarioLogado usuarioLogado = new UsuarioLogado(usuarioOmnion, senha);
            HttpContext.Current.Session["UsuarioOmnion"] = usuarioLogado;
            HttpContext.Current.User = p;
            Thread.CurrentPrincipal = p;
        }
Пример #2
0
 public UsuarioLogado(Laboris.Cosan.Service.Omnion.Login omnionLogin, string senha)
 {
     _omnionLogin = omnionLogin;
     _senha = senha;
 }
Пример #3
0
 public UsuarioLogado(Laboris.Cosan.Domain.Usuario usuario, string senha)
 {
     _usuario = usuario;
     _senha = senha;
 }
Пример #4
0
        public void RegistrarLogin(string cpf, Laboris.Cosan.Service.Omnion.Login usuarioOmnion, string senha)
        {
            HttpCookie authCookie = FormsAuthentication.GetAuthCookie(cpf, false);

            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
            FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, usuarioOmnion.Nome);

            authCookie.Value = FormsAuthentication.Encrypt(newTicket);
            authCookie.Path = FormsAuthentication.FormsCookiePath;

            Response.Cookies.Add(authCookie);

            IPrincipal p = new GenericPrincipal(new FormsIdentity(newTicket), null);

            // Attach the CustomPrincipal to HttpContext.User and Thread.CurrentPrincipal
            UsuarioLogado usuarioLogado = new UsuarioLogado(usuarioOmnion, senha);
            HttpContext.Current.Session["UsuarioOmnion"] = usuarioLogado;
            HttpContext.Current.User = p;
            Thread.CurrentPrincipal = p;

            //string redirUrl = FormsAuthentication.GetRedirectUrl(txtCpf.Text, false);
            /*
            IPrincipal usr = HttpContext.Current.User;

            FormsIdentity fIdent = usr.Identity as FormsIdentity;
            */
        }