X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FLoginPage.java;h=dcfd8a7642057ab406a4df8983c287ab3c8f6f77;hb=0ac5c61faa54b62f29bf8c8e9903919315810c80;hp=4a3e2b158e129ee73f2fa858f4bacad82c682db5;hpb=2c5b76a2fbce16ef33f079a3de9ae9fc9a9d30b8;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/web/LoginPage.java b/src/main/java/net/pterodactylus/sone/web/LoginPage.java index 4a3e2b1..dcfd8a7 100644 --- a/src/main/java/net/pterodactylus/sone/web/LoginPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LoginPage.java @@ -63,27 +63,32 @@ public class LoginPage extends SoneTemplatePage { protected void processTemplate(Request request, Template template) throws RedirectException { super.processTemplate(request, template); /* get all own identities. */ - List localSones = new ArrayList(webInterface.core().getLocalSones()); + List localSones = new ArrayList(webInterface.getCore().getLocalSones()); Collections.sort(localSones, Sone.NICE_NAME_COMPARATOR); template.set("sones", localSones); if (request.getMethod() == Method.POST) { String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone-id", 100); - Sone selectedSone = null; - for (Sone sone : webInterface.core().getSones()) { - if (sone.getId().equals(soneId)) { - selectedSone = sone; - break; - } - } + Sone selectedSone = webInterface.getCore().getLocalSone(soneId, false); if (selectedSone != null) { setCurrentSone(request.getToadletContext(), selectedSone); throw new RedirectException("index.html"); } } - List ownIdentitiesWithoutSone = CreateSonePage.getOwnIdentitiesWithoutSone(webInterface.core()); + List ownIdentitiesWithoutSone = CreateSonePage.getOwnIdentitiesWithoutSone(webInterface.getCore()); template.set("identitiesWithoutSone", ownIdentitiesWithoutSone); } + /** + * {@inheritDoc} + */ + @Override + protected String getRedirectTarget(Request request) { + if (getCurrentSone(request.getToadletContext()) != null) { + return "index.html"; + } + return null; + } + // // SONETEMPLATEPAGE METHODS //