java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java | 25 -------- java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java | 2 java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java | 29 +++++++++- 3 files changed, 30 insertions(+), 26 deletions(-)
New commits: commit fbadff4927b0ca257cdd29a175507e8cbd600faf Author: Johannes Renner jrenner@suse.de Date: Wed Oct 12 13:23:01 2011 +0200
Fixed pam setting on user page not saving
diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java index e34b726..9ebb627 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java @@ -14,8 +14,6 @@ */ package com.redhat.rhn.frontend.action.user;
-import com.redhat.rhn.common.conf.Config; -import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.common.security.PermissionException; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.role.Role; @@ -79,33 +77,12 @@ public class AdminUserEditAction extends UserEditActionHelper { User loggedInUser = requestContext.getLoggedInUser();
//Update the users details with info entered on the form - ActionErrors errors = updateDetails(targetUser, form); + ActionErrors errors = updateDetails(loggedInUser, targetUser, form); //If we have validation/form errors, return now and let the user fix those first if (!errors.isEmpty()) { return returnFailure(mapping, request, errors, targetUser.getId()); }
- /* - * Update PAM Authentication attribute - * If we're a satellite that is configured to use pam and the loggedIn user is an - * org_admin (and therefore the checkbox was displayed), we need to inspect the - * "usepam" field on the form and set the targetUser's pam auth attribute - * accordingly. (we don't want to set this field if it wasn't displayed or if the - * user doesn't have access to set this attribute) - */ - String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE); - if (pamAuthService != null && - pamAuthService.trim().length() > 0 && - loggedInUser.hasRole(RoleFactory.ORG_ADMIN)) { - if (form.get("usepam") != null && - ((Boolean) form.get("usepam")).booleanValue()) { - targetUser.setUsePamAuthentication(true); - } - else { - targetUser.setUsePamAuthentication(false); - } - } - //Create the user info updated success message createSuccessMessage(request, "message.userInfoUpdated", null);
diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java index d7f8dcc..6917c38 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java @@ -44,7 +44,7 @@ public class SelfEditAction extends UserEditActionHelper { RequestContext requestContext = new RequestContext(request); User user = requestContext.getLoggedInUser();
- ActionErrors errors = updateDetails(user, form); + ActionErrors errors = updateDetails(user, user, form);
//If there are no errors, store the user and return the success mapping if (errors.isEmpty()) { diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java b/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java index 14e47ed..98e3619 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java +++ b/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java @@ -14,6 +14,9 @@ */ package com.redhat.rhn.frontend.action.user;
+import com.redhat.rhn.common.conf.Config; +import com.redhat.rhn.common.conf.ConfigDefaults; +import com.redhat.rhn.domain.role.RoleFactory; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.frontend.struts.RhnValidationHelper; @@ -31,11 +34,12 @@ public abstract class UserEditActionHelper extends RhnAction {
/** * This method handles the common tasks between SelfEditAction and AdminUserEditAction. + * @param loggedInUser logged in user * @param targetUser The user to operate on * @param form The form we're grabbing the info from * @return Returns an ActionErrors object containing the errors (if any) that occurred. */ - public ActionErrors updateDetails(User targetUser, DynaActionForm form) { + public ActionErrors updateDetails(User loggedInUser, User targetUser, DynaActionForm form) {
//get validation errors ActionErrors errors = RhnValidationHelper.validateDynaActionForm(this, form); @@ -63,8 +67,31 @@ public abstract class UserEditActionHelper extends RhnAction { targetUser.setLastName((String)form.get("lastName")); targetUser.setTitle((String)form.get("title")); targetUser.setPrefix((String)form.get("prefix")); + // Update PAM Authentication attribute + updatePamAttribute(loggedInUser, targetUser, form); }
return errors; } + + /** + * If pam is configured and the loggedInUser is an org_admin (and therefore + * the checkbox was displayed), we need to inspect the "usepam" field on the + * form and set the targetUser's pam auth attribute accordingly. + * @param loggedInUser The user who is currently logged in + * @param targetUser The user that will be updated + * @param form The form containing the attribute value to use + */ + protected void updatePamAttribute(User loggedInUser, User targetUser, DynaActionForm form) { + String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE); + if (pamAuthService != null && pamAuthService.trim().length() > 0 + && loggedInUser.hasRole(RoleFactory.ORG_ADMIN)) { + if (form.get("usepam") != null + && ((Boolean) form.get("usepam")).booleanValue()) { + targetUser.setUsePamAuthentication(true); + } else { + targetUser.setUsePamAuthentication(false); + } + } + } }
spacewalk-commits@lists.fedorahosted.org