diff --git a/changelog.html b/changelog.html index bd352fc4..8c528bb6 100644 --- a/changelog.html +++ b/changelog.html @@ -44,8 +44,10 @@

Just married Plugin Changelog

-

1.2.5 -- (TBD)

+

1.3.0 -- (TBD)

1.2.4 -- November 11, 2020

diff --git a/plugin.xml b/plugin.xml index 37cf8104..8a0c431e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,8 +5,8 @@ Allows admins to rename or copy users Holger Bergunde ${project.version} - 2020-11-11 - 4.0.0 + 2024-11-20 + 4.6.0 diff --git a/pom.xml b/pom.xml index 267e9c1a..1321657b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ plugins org.igniterealtime.openfire - 4.3.0-beta + 4.6.0 org.igniterealtime.openfire.plugins justmarried - 1.2.5-SNAPSHOT + 1.3.0-SNAPSHOT JustMarried Plugin Allows admins to rename or copy users diff --git a/src/java/org/jivesoftware/openfire/plugin/married/JustMarriedPlugin.java b/src/java/org/jivesoftware/openfire/plugin/married/JustMarriedPlugin.java index 50cfa88b..d9b1e1b8 100644 --- a/src/java/org/jivesoftware/openfire/plugin/married/JustMarriedPlugin.java +++ b/src/java/org/jivesoftware/openfire/plugin/married/JustMarriedPlugin.java @@ -32,13 +32,15 @@ public void initializePlugin(PluginManager manager, File pluginDirectory) { } public static boolean changeName(String currentUserName, String newUserName, boolean deleteOldUser, - String newEmail, String newRealName) { + String newEmail, String newRealName, String password) { UserManager userManager = UserManager.getInstance(); try { User currentUser = userManager.getUser(currentUserName); // Old user found, create new one - String password = AuthFactory.getPassword(currentUserName); + if (password == null || password.isEmpty()) { + password = AuthFactory.getPassword(currentUserName); + } String newName = (newRealName == null || newRealName.length() == 0) ? currentUser.getName() : newRealName; String newMail = (newEmail == null || newEmail.length() == 0) ? currentUser.getEmail() : newEmail; User newUser = userManager.createUser(newUserName, password, currentUser.getName(), newMail); @@ -145,7 +147,7 @@ private static void addNewUserToOthersRoster(User newUser, RosterItem otherItem, // Is this user registered with our OF server? String username = otherItem.getJid().getNode(); - if (username != null && username.length() > 0 && userManager.isRegisteredUser(username) + if (username != null && username.length() > 0 && userManager.isRegisteredUser(otherItem.getJid(), false) && XMPPServer.getInstance().isLocal(XMPPServer.getInstance().createJID(currentUser, null))) { try { User otherUser = userManager.getUser(username); diff --git a/src/web/married.jsp b/src/web/married.jsp index a1cbf76a..3858f40f 100644 --- a/src/web/married.jsp +++ b/src/web/married.jsp @@ -1,5 +1,7 @@ <%@ page contentType="text/html; charset=UTF-8" %> <%@ page import="org.jivesoftware.openfire.plugin.married.JustMarriedPlugin"%> +<%@ page import="org.jivesoftware.openfire.auth.AuthFactory" %> +<%@ page import="org.jivesoftware.openfire.user.UserManager" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> @@ -8,9 +10,12 @@ webManager.init(request, response, session, application, out); String oldName = request.getParameter("oldName"); String newName = request.getParameter("newName"); + String newPassword = request.getParameter("newPassword"); String keepCopy = request.getParameter("copy"); String newEmail = request.getParameter("email"); String newRealName = request.getParameter("realName"); + + final boolean supported = !UserManager.getUserPropertyProvider().isReadOnly(); %> @@ -24,13 +29,29 @@ + <% if (!supported) { %> +
+ + + + + + + +
+ This instance of Openfire does not support this feature, as its user-base is 'read-only' (likely due to being obtained from a remote directory service). +
+
+
+ <% } %> +
Just married
<% if (oldName != null && newName != null && oldName.trim().length() > 0 && newName.trim().length() > 0) { - boolean success = JustMarriedPlugin.changeName(oldName, newName, keepCopy == null ? true : false, newEmail, newRealName); + boolean success = JustMarriedPlugin.changeName(oldName, newName, keepCopy == null ? true : false, newEmail, newRealName, newPassword); if (success) { - out.write("
Sucessfully renamed user " + oldName + " to " + newName + out.write("
Successfully renamed user " + oldName + " to " + newName + "!
"); } else { out.write("
Something went wrong :-/. Please have a closer look to the error log!
"); @@ -46,7 +67,7 @@ : "class=\"controls\"");%>> > + <%out.write(oldName != null && oldName.length() == 0 ? "id=\"inputError\"" : "id=\"input01\"");%> <%=supported?"":"disabled"%> required>

The current username e.g user.name (without server)

@@ -56,30 +77,40 @@ : "class=\"controls\"");%>> > -

The new username e.g user.newname + <%out.write(newName != null && newName.length() == 0 ? "id=\"inputError\"" : "id=\"input01\"");%> <%=supported?"":"disabled"%> required> +

The new username e.g. user.newname (without server)

+ +
> + <%=supported?"":"disabled"%> <%=AuthFactory.supportsPasswordRetrieval()?"":"required"%>> +

The new password for this user. <%=AuthFactory.supportsPasswordRetrieval()?"Leave empty to keep the old password.":""%>

+
+
+ class="input-xlarge" id="input01" <%=supported?"":"disabled"%>>

New email address. Will copy address from old user if field is empty.

+ class="input-xlarge" id="input01" <%=supported?"":"disabled"%>>

Will copy name from old user if field is empty.

- +

* Mandatory item