Esempio n. 1
0
        private void btnDocMenuVolver_Click(object sender, EventArgs e)
        {
            LoginPrincipal LogPrinDoc = new LoginPrincipal();

            LogPrinDoc.Show();
            this.Hide();
        }
Esempio n. 2
0
        private void btnRegUsVolver_Click(object sender, EventArgs e)
        {
            LoginPrincipal LogPrinRegUs = new LoginPrincipal();

            LogPrinRegUs.Show();
            this.Hide();
        }
Esempio n. 3
0
        private void buttbtnAdmMenuVolver_Click(object sender, EventArgs e)
        {
            LoginPrincipal LogPrinAdmin = new LoginPrincipal();

            LogPrinAdmin.Show();

            this.Hide();
        }
Esempio n. 4
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Event handler. Called by Application for acquire request state events. </summary>
        ///
        /// <remarks>   Rafiqul Islam, 12/2/2015. </remarks>
        ///
        /// <param name="sender">   Source of the event. </param>
        /// <param name="e">        Event information. </param>
        ///-------------------------------------------------------------------------------------------------

        protected void Application_AcquireRequestState(object sender, EventArgs e)
        {
            try
            {
                HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie != null && authCookie.Value != "")
                {
                    FormsAuthenticationTicket ticket   = FormsAuthentication.Decrypt(authCookie.Value);
                    LoginIdentity             identity = new LoginIdentity(ticket.UserData);
                    var basicTicket = Application["BasicTicket" + identity.Name];
                    var roleTicket  = Application["RoleTicket" + identity.Name];
                    if (basicTicket != null && roleTicket != null && basicTicket.ToString() == ticket.UserData)
                    {
                        identity.SetRoles(roleTicket.ToString());
                        LoginPrincipal principal = new LoginPrincipal(identity);
                        HttpContext.Current.User = principal;
                        Thread.CurrentPrincipal  = principal;
                        FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, FormsAuthentication.FormsCookieName, DateTime.Now, DateTime.Now.AddMinutes(720), ticket.IsPersistent, ticket.UserData);
                        string encTicket = FormsAuthentication.Encrypt(authTicket);
                        HttpContext.Current.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
                        return;
                    }
                    authCookie.Expires = DateTime.Now.AddDays(-1);
                    HttpContext.Current.Response.Cookies.Add(authCookie);
                    Application["BasicTicket" + identity.Name] = null;
                    Application["RoleTicket" + identity.Name]  = null;
                    if (HttpContext.Current.Request.Path.ToUpper().StartsWith("/CPANEL"))
                    {
                        HttpContext.Current.Response.Redirect("/Login/cpanel");
                    }
                    if (HttpContext.Current.Request.Path.ToUpper().StartsWith("/APanel"))
                    {
                        HttpContext.Current.Response.Redirect("/Login");
                    }
                }
                else
                {
                    //HttpContext.Current.Response.Redirect("http://localhost:44372");  // = //new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "Login" } });
                    //HttpContext.Current.RewritePath("http://localhost:44372/");
                }
            }
            catch (Exception ex)
            {
                var fail = ex.Message;
                FormsAuthentication.SignOut();
            }
        }
Esempio n. 5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            LoginPrincipal loginPrincipal = new LoginPrincipal();

            AppDomain.CurrentDomain.SetThreadPrincipal(loginPrincipal);
            base.OnStartup(e);
            MainWindowBaseViewModel viewModel = new MainWindowBaseViewModel(new AuthenticationService());
            EventHandler            handler   = null;
            IView loginWindow = new MainWindow(viewModel);

            handler = delegate
            {
                viewModel.RequestClose -= handler;
                loginWindow.Close();
            };
            viewModel.RequestClose += handler;
            loginWindow.Show();
        }
Esempio n. 6
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            var authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie == null)
            {
                return;
            }

            var authTicket = FormsAuthentication.Decrypt(authCookie.Value);

            var serializeModel = JsonConvert.DeserializeObject <UsuarioLogadoViewModel>(authTicket.UserData);

            if (serializeModel == null)
            {
                return;
            }

            var newUser = new LoginPrincipal(serializeModel);

            HttpContext.Current.User = newUser;
        }
Esempio n. 7
0
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie != null)
            {
                // Get the forms authentication ticket.
                //string unZipCookie = ZipLib.UnZip(authCookie.Value);
                FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
                var identity  = new GenericIdentity(authTicket.Name, "Forms");
                var principal = new LoginPrincipal(identity);

                // Get the custom user data encrypted in the ticket.
                string userData = ((FormsIdentity)(Context.User.Identity)).Ticket.UserData;

                // Deserialize the json data and set it on the custom principal.
                var serializer = new JavaScriptSerializer();
                principal.User = (Ticket)serializer.Deserialize(userData, typeof(Ticket));

                // Set the context user.
                Context.User = principal;
            }
        }