diff --git a/backoffice/src/main/java/uy/edu/fing/tse/jsf/UserLoginBean.java b/backoffice/src/main/java/uy/edu/fing/tse/jsf/UserLoginBean.java index fb192031d8e38b30a47e0c3e29a79b92dcb0f5d4..20e8e9b70e7f922d1f7522176b46567f73bf7f33 100644 --- a/backoffice/src/main/java/uy/edu/fing/tse/jsf/UserLoginBean.java +++ b/backoffice/src/main/java/uy/edu/fing/tse/jsf/UserLoginBean.java @@ -40,6 +40,8 @@ public class UserLoginBean implements Serializable { private String repassword; + private String token; + public List<Role> getRoles() { return roles; } @@ -60,12 +62,33 @@ public class UserLoginBean implements Serializable { this.repassword = repassword; } - public void login() { + public String getToken() { + return token; + } - final var s = securityLocal.login(user); - LOG.info(s); + public void setToken(String token) { + this.token = token; } + public String login() { + token = securityLocal.login(user); + + if (token != null) { + try {//TODO sacar + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return "gestionhechos"; + } else { + FacesContext.getCurrentInstance().addMessage( + null, + new FacesMessage(FacesMessage.SEVERITY_WARN, + "Ingreso incorrecto", + "Por favor verificar los datos ingresados")); + return ""; + } + } public String register() { boolean valid = true; diff --git a/backoffice/src/main/webapp/jsf/login.xhtml b/backoffice/src/main/webapp/jsf/login.xhtml index ff78a6ad5ffc56e7f6d1d0b16aca7b2e5edc29a1..8ef52341a5dd28edb44e856a07819dea7eec2e1f 100644 --- a/backoffice/src/main/webapp/jsf/login.xhtml +++ b/backoffice/src/main/webapp/jsf/login.xhtml @@ -14,17 +14,19 @@ <h:panelGrid columns="3" cellpadding="5" id="form"> <h:outputLabel for="username" value="Username:"/> - <p:inputText id="username" value="#{userLoginView.user.mail}" required="true" requiredMessage="Ingrese su e-mail" label="username"/> + <p:inputText id="username" value="#{userLoginView.user.mail}" required="true" + requiredMessage="Ingrese su e-mail" label="username"/> <p:message id="msgName" for="username"/> <h:outputLabel for="password" value="Password:"/> - <p:password id="password" value="#{userLoginView.user.password}" required="true" requiredMessage="Ingrese: su password" label="password"/> + <p:password id="password" value="#{userLoginView.user.password}" required="true" + requiredMessage="Ingrese: su password" label="password"/> <p:message id="msgPassword" for="password"/> <f:facet name="footer"> <p:commandButton value="Register" action="register.xhmtl?faces-redirect=true" update="form" async="true" process="@this"/> <p:commandButton value="Login" action="#{userLoginView.login()}" update="form"/> </f:facet> - + <h:outputLabel value="#{userLoginView.token}"/> </h:panelGrid> </h:form> </ui:define>