Пример #1
0
        public ActionResult Edit(int id)
        {
            ObjectsList(id);

            var usuarios = new Usuarios();

            var bll = new UsuariosBll();

            var usuario = new Usuarios(id);

            usuarios = bll.GetObject(usuario);

            if (usuarios == null)
            {
                return(HttpNotFound());
            }

            return(View(usuarios));

            //var bll = new UsuariosBll();
            //var usuario = bll.GetObject(id);



            //if (usuario == null)
            //{
            //    return HttpNotFound();
            //}

            //return View(usuario);
        }
Пример #2
0
        protected void FormsAuthentication_OnAuthenticate(Object sender, FormsAuthenticationEventArgs e)
        {
            if (FormsAuthentication.CookiesSupported)
            {
                if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
                {
                    try
                    {
                        //let us take out the username now
                        var formsAuthenticationTicket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value);
                        if (formsAuthenticationTicket != null)
                        {
                            string username = formsAuthenticationTicket.Name;//Cpf
                            string roles    = string.Empty;

                            var bll     = new UsuariosBll();
                            var usuario = bll.GetObject(username);

                            roles = usuario.Perfil.Nome;

                            //Let us set the Pricipal with our user specific details
                            e.User = new System.Security.Principal.GenericPrincipal(
                                new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(';'));
                        }
                    }
                    catch (Exception)
                    {
                        //somehting went wrong
                    }
                }
            }
        }