From eaf95b403f6c208fa3ec542bb447fa423e779313 Mon Sep 17 00:00:00 2001
From: Falucho <german.faller@pcunix71.fing.edu.uy>
Date: Mon, 24 Jun 2019 13:16:32 -0300
Subject: [PATCH] Fix Registro

---
 .../java/uy/edu/fing/tse/jsf/UserLoginBean.java     | 11 +++++++----
 backoffice/src/main/webapp/jsf/login.xhtml          |  5 +++--
 backoffice/src/main/webapp/jsf/register.xhtml       | 13 ++++++-------
 3 files changed, 16 insertions(+), 13 deletions(-)

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 0e01fa1..fb19203 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
@@ -37,6 +37,7 @@ public class UserLoginBean implements Serializable {
     }
 
     final UserBO user = new UserBO();
+
     private String repassword;
 
     public List<Role> getRoles() {
@@ -59,7 +60,6 @@ public class UserLoginBean implements Serializable {
         this.repassword = repassword;
     }
 
-
     public void login() {
 
         final var s = securityLocal.login(user);
@@ -68,11 +68,14 @@ public class UserLoginBean implements Serializable {
 
 
     public String register() {
-        final var s = securityLocal.register(user);
-        boolean valid = false;   // verificar que sean iguales la pasw, en caso contrario
+        boolean valid = true;
 
+        // verificar que sean iguales la pasw, en caso contrario
+        valid &= user.getPassword().equals(repassword);
+        //Verificar que no existe usuario
+        //TODO
         if (valid) {
-
+            final var s = securityLocal.register(user);
             return "gestionhechos";
         } else {
             FacesContext.getCurrentInstance().addMessage(
diff --git a/backoffice/src/main/webapp/jsf/login.xhtml b/backoffice/src/main/webapp/jsf/login.xhtml
index 83d6728..ff78a6a 100644
--- a/backoffice/src/main/webapp/jsf/login.xhtml
+++ b/backoffice/src/main/webapp/jsf/login.xhtml
@@ -20,8 +20,9 @@
                 <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" />
+                    <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:panelGrid>
diff --git a/backoffice/src/main/webapp/jsf/register.xhtml b/backoffice/src/main/webapp/jsf/register.xhtml
index 0c84897..0cc5d4a 100644
--- a/backoffice/src/main/webapp/jsf/register.xhtml
+++ b/backoffice/src/main/webapp/jsf/register.xhtml
@@ -29,20 +29,19 @@
 
 
                 <p:outputLabel for="rol" value="Rol:"/>
-                <p:selectOneRadio id="rol" value="#{userLoginView.user.role}" unselectable="false">
-                    <f:selectItems value="#{userLoginView.roles}" var="r" itemLabel="#{r.name}" itemValue="#{r}"/>
+                <p:selectOneRadio id="rol" value="#{userLoginView.user.role.name}" unselectable="false">
+                    <f:selectItems value="#{userLoginView.roles}" var="r" itemLabel="#{r.name}" itemValue="#{r.name}"/>
                 </p:selectOneRadio>
 
 
                 <f:facet name="footer">
-
-                    <h:commandButton styleClass="btn btn-primary" vaction="#{userLoginView.register}" value="Register"
-                                     style="font-size:20px"/>
+                    <h:commandButton styleClass="btn btn-primary" action="#{userLoginView.register()}"
+                                     value="Crear Usuario" style="font-size:20px"/>
 
                     <h:commandButton styleClass="btn btn-primary" value="Volver"
-                                     action="login.xhmtl?faces-redirect=true" update="form" async="true" process="@this"
+                                     action="login.xhmtl?faces-redirect=true"
+                                     update="form" async="true" process="@this"
                                      style="font-size:20px"/>
-
                 </f:facet>
 
             </h:panelGrid>
-- 
GitLab