You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by sk...@apache.org on 2020/02/25 11:51:00 UTC

[syncope] branch SYNCOPE-1537 created (now f4bdffc)

This is an automated email from the ASF dual-hosted git repository.

skylark17 pushed a change to branch SYNCOPE-1537
in repository https://gitbox.apache.org/repos/asf/syncope.git.


      at f4bdffc  [SYNCOPE-1537] Password and username of LinkedAccounts now saved properly from Admin Console

This branch includes the following new commits:

     new f4bdffc  [SYNCOPE-1537] Password and username of LinkedAccounts now saved properly from Admin Console

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[syncope] 01/01: [SYNCOPE-1537] Password and username of LinkedAccounts now saved properly from Admin Console

Posted by sk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

skylark17 pushed a commit to branch SYNCOPE-1537
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit f4bdffcb2715c44c422989ea27b77a25161e3f4f
Author: skylark17 <sk...@apache.org>
AuthorDate: Tue Feb 25 12:50:36 2020 +0100

    [SYNCOPE-1537] Password and username of LinkedAccounts now saved properly from Admin Console
---
 .../wizards/any/LinkedAccountCredentialsPanel.java | 52 +++++++++++++---------
 .../wizards/any/LinkedAccountWizardBuilder.java    | 10 ++---
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountCredentialsPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountCredentialsPanel.java
index bb04ada..089968b 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountCredentialsPanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountCredentialsPanel.java
@@ -42,39 +42,42 @@ public class LinkedAccountCredentialsPanel extends WizardStep {
 
     private static final long serialVersionUID = 5116461957402341603L;
 
-    public LinkedAccountCredentialsPanel(final LinkedAccountTO linkedAccountTO) {
+    private final LinkedAccountTO linkedAccountTO;
+
+    public LinkedAccountCredentialsPanel(final EntityWrapper<LinkedAccountTO> modelObject) {
         super();
         setOutputMarkupId(true);
 
+        linkedAccountTO = modelObject.getInnerObject();
+
         AjaxTextFieldPanel usernameField = new AjaxTextFieldPanel(
                 "username",
                 "username",
-                new PropertyModel<>(linkedAccountTO, "username"),
-                false);
-        usernameField.setOutputMarkupId(true);
+                new PropertyModel<>(linkedAccountTO, "username"));
         FieldPanel.class.cast(usernameField).setReadOnly(StringUtils.isBlank(linkedAccountTO.getUsername()));
-        LinkedAccountPlainAttrProperty property = new LinkedAccountPlainAttrProperty();
-        property.setOverridable(StringUtils.isNotBlank(linkedAccountTO.getUsername()));
-        property.setSchema("username");
-        property.getValues().add(linkedAccountTO.getUsername());
-        usernameField.showExternAction(checkboxToggle(property, usernameField));
-        add(usernameField);
+        LinkedAccountPlainAttrProperty usernameProperty = new LinkedAccountPlainAttrProperty();
+        usernameProperty.setOverridable(StringUtils.isNotBlank(linkedAccountTO.getUsername()));
+        usernameProperty.setSchema("username");
+        usernameProperty.getValues().add(linkedAccountTO.getUsername());
+        usernameField.showExternAction(checkboxToggle(usernameProperty, usernameField));
+        add(usernameField.setOutputMarkupId(true));
 
         AjaxPasswordFieldPanel passwordField = new AjaxPasswordFieldPanel(
                 "password",
                 "password",
-                new PropertyModel<>(linkedAccountTO, "password"));
-        passwordField.setOutputMarkupId(true);
-        passwordField.setRequired(true);
+                new PropertyModel<>(linkedAccountTO, "password"),
+                false);
         passwordField.setMarkupId("password");
+        passwordField.setPlaceholder("password");
+        passwordField.setRequired(true);
         FieldPanel.class.cast(passwordField).setReadOnly(StringUtils.isBlank(linkedAccountTO.getPassword()));
-        property = new LinkedAccountPlainAttrProperty();
-        property.setOverridable(StringUtils.isNotBlank(linkedAccountTO.getPassword()));
-        property.setSchema("password");
-        property.getValues().add(linkedAccountTO.getPassword());
-        passwordField.showExternAction(checkboxToggle(property, passwordField));
-        ((PasswordTextField) passwordField.getField()).setResetPassword(true);
-        add(passwordField);
+        LinkedAccountPlainAttrProperty passwordProperty = new LinkedAccountPlainAttrProperty();
+        passwordProperty.setOverridable(StringUtils.isNotBlank(linkedAccountTO.getPassword()));
+        passwordProperty.setSchema("password");
+        passwordProperty.getValues().add(linkedAccountTO.getPassword());
+        passwordField.showExternAction(checkboxToggle(passwordProperty, passwordField));
+        ((PasswordTextField) passwordField.getField()).setResetPassword(false);
+        add(passwordField.setOutputMarkupId(true));
     }
 
     private FormComponent<?> checkboxToggle(
@@ -98,7 +101,14 @@ public class LinkedAccountCredentialsPanel extends WizardStep {
 
                     @Override
                     protected void onUpdate(final AjaxRequestTarget target) {
-                        panel.setReadOnly(!model.getObject());
+                        FieldPanel.class.cast(panel).setReadOnly(!model.getObject());
+                        if (!model.getObject()) {
+                            if (property.getSchema().equals("password")) {
+                                linkedAccountTO.setPassword(null);
+                            } else if (property.getSchema().equals("username")) {
+                                linkedAccountTO.setUsername(null);
+                            }
+                        }
                         target.add(panel);
                     }
                 });
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountWizardBuilder.java
index 7446344..8c5076d 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/LinkedAccountWizardBuilder.java
@@ -60,7 +60,7 @@ public class LinkedAccountWizardBuilder extends AjaxWizardBuilder<LinkedAccountT
     @Override
     protected WizardModel buildModelSteps(final LinkedAccountTO modelObject, final WizardModel wizardModel) {
         wizardModel.add(new LinkedAccountDetailsPanel(modelObject));
-        wizardModel.add(new LinkedAccountCredentialsPanel(modelObject));
+        wizardModel.add(new LinkedAccountCredentialsPanel(new EntityWrapper<>(modelObject)));
         wizardModel.add(new LinkedAccountPlainAttrsPanel(new EntityWrapper<>(modelObject), model.getObject()));
         wizardModel.add(new LinkedAccountPrivilegesPanel(modelObject));
         return wizardModel;
@@ -72,10 +72,10 @@ public class LinkedAccountWizardBuilder extends AjaxWizardBuilder<LinkedAccountT
 
         LinkedAccountPatch linkedAccountPatch = new LinkedAccountPatch.Builder().linkedAccountTO(modelObject).build();
         linkedAccountPatch.setLinkedAccountTO(modelObject);
-        UserPatch patch = new UserPatch();
-        patch.setKey(model.getObject().getKey());
-        patch.getLinkedAccounts().add(linkedAccountPatch);
-        model.setObject(userRestClient.update(model.getObject().getETagValue(), patch).getEntity());
+        UserPatch userPatch = new UserPatch();
+        userPatch.setKey(model.getObject().getKey());
+        userPatch.getLinkedAccounts().add(linkedAccountPatch);
+        model.setObject(userRestClient.update(model.getObject().getETagValue(), userPatch).getEntity());
 
         return modelObject;
     }