Example #1
0
        protected void btnLogar_Click(object sender, EventArgs e)
        {
            if (rdoAnunciante.Checked)
            {
                var usuarioLogado = new ComercioDAO().Logar(txtEmail.Text, txtSenha.Text);

                if (usuarioLogado == null)
                {
                    pnlMSG.Visible = true;
                    lblMSG.Text    = "Login e/ou Senha inválida!";
                    txtSenha.Focus();
                    return;
                }

                var userData = new JavaScriptSerializer().Serialize(new Usuario()
                {
                    Id    = usuarioLogado.Id,
                    Nome  = usuarioLogado.Nome,
                    Email = usuarioLogado.Email
                });

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

                Response.Redirect(string.Format("~/GerenciamentoComercio.aspx?id={0}", usuarioLogado.Id));
            }
            else
            {
                var usuarioLogado = new ConsumidorDAO().Logar(txtEmail.Text, txtSenha.Text);

                if (usuarioLogado == null)
                {
                    pnlMSG.Visible = true;
                    lblMSG.Text    = "Login e/ou Senha inválida!";
                    txtSenha.Focus();
                    return;
                }

                var userData = new JavaScriptSerializer().Serialize(new Usuario()
                {
                    Id    = usuarioLogado.Id,
                    Nome  = usuarioLogado.Nome,
                    Email = usuarioLogado.Email
                });

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

                Response.Redirect("~/Default.aspx");
            }
        }
Example #2
0
 protected void lnkSair_Click(object sender, EventArgs e)
 {
     FormsAuthenticationUtil.SignOut();
     Response.Redirect("~/Login.aspx");
 }