Validate user login

Asked

Viewed 327 times

0

I’m not able to validate the user login. Could someone give me a help?

My Dao:

public Login getvalidarLogin(Login login ){

    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction t = session.beginTransaction();
    try{
        Query query = session.createQuery("from login where login_login='"+login.getLogin_login()+"' and login_senha='"+login.getLogin_senha()+"'");
        login = (Login)query.uniqueResult();
        t.commit();

    }catch(HibernateException e){
        System.out.println("ERRO AO VALIDAR LOGIN .Erro: >>>>>>" + e.getMessage());
    }
    return login;
}

My Bean:

public String validacaoLogin(){

    login = dao.getvalidarLogin(login);
    if(login != null){
        login = new Login();
        FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(FacesMessage.SEVERITY_ERROR, "Usuário não encontrado!","Erro no Login!"));
        return null;
    } else {
            return "medico/medicoView";
        }
    }
  • Are you making an exception?

  • select login0_.id_login asid1_16_, login0_.login_login aslogin2_16_, login0_.login_password aslogin3_16_, login0_.type_user astype4_16_ from loginlogin0_ Where login0_.login_login='farmacia' and login0_.login_password='123' oct 13, 2015 10:53:18 AM com.sun.faces.renderkit.Renderkitutils renderUnhandledMessages INFO: WARNING: Facesmessage(s) have been lined up, but may not have been shown. sourceId=null[Severity=(ERROR 2), Summary=(Usual not found! ), Detail=(Login Error!)]

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.