X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FLoginPage.java;h=c34d8caa75836e371689a4086553b37fc935ab87;hb=feed7f41366c0d638e7c2b0d9f9ccbd1ee19927d;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..c34d8ca 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); 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 //