X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FEditProfileFieldPage.java;h=bbc6d6b00d8f2df0299a14b9fa4d8ea09d81d6dd;hp=a06592a7e4d54a5a9faf20422026a81c67e0f28f;hb=9acbc5bdec4ccb752e0856a501568b0bb6161579;hpb=38cb6c5ec82298ee351d0eb15ddd8331db273af2 diff --git a/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java b/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java index a06592a..bbc6d6b 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditProfileFieldPage.java - Copyright © 2011 David Roden + * Sone - EditProfileFieldPage.java - Copyright © 2011–2016 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,8 +52,7 @@ public class EditProfileFieldPage extends SoneTemplatePage { * {@inheritDoc} */ @Override - protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { - super.processTemplate(request, templateContext); + protected void handleRequest(FreenetRequest request, TemplateContext templateContext) throws RedirectException { Sone currentSone = getCurrentSone(request.getToadletContext()); Profile profile = currentSone.getProfile(); @@ -76,12 +75,15 @@ public class EditProfileFieldPage extends SoneTemplatePage { } String name = request.getHttpRequest().getPartAsStringFailsafe("name", 256); Field existingField = profile.getFieldByName(name); - if ((existingField == null) || (existingField.equals(field))) { - field.setName(name); - currentSone.setProfile(profile); + if ((existingField != null) && (!field.equals(existingField))) { + templateContext.set("duplicateFieldName", true); + } else { + if (!name.equals(field.getName())) { + field.setName(name); + currentSone.setProfile(profile); + } throw new RedirectException("editProfile.html#profile-fields"); } - templateContext.set("duplicateFieldName", true); } /* store current values in template. */