示例#1
0
        protected void btnEntrar_Click(object sender, EventArgs e)
        {
            if (!Validar())
            {
                pnlMsg.Visible = true;
                return;
            }

            var usuarioLogado = new UsuarioDAO().Logar(new Usuario()
            {
                Email = txtEmail.Text,
                Senha = txtSenha.Text,
            });

            if (usuarioLogado == null)
            {
                pnlMsg.Visible = true;
                return;
            }

            var userData = new JavaScriptSerializer().Serialize(usuarioLogado);

            FormsAuthenticationUtil.SetCustomAuthCookie(usuarioLogado.Email, userData, false);

            if (usuarioLogado.Administrador)
            {
                Response.Redirect("~/DefaultAdm.aspx");
            }
            Response.Redirect("~/Default.aspx");
        }
示例#2
0
 protected void lnkSair_Click(object sender, EventArgs e)
 {
     FormsAuthenticationUtil.SignOut();
     Response.Redirect("~/Login.aspx");
 }