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=1e281b5eecc0ae3a38aa5b47e50339cb0699bd66;hpb=bd2cbb229f68fb2535cf6010befa9c4a276d2ee6;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 1e281b5..dcfd8a7 100644 --- a/src/main/java/net/pterodactylus/sone/web/LoginPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LoginPage.java @@ -68,13 +68,7 @@ public class LoginPage extends SoneTemplatePage { template.set("sones", localSones); if (request.getMethod() == Method.POST) { String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone-id", 100); - Sone selectedSone = null; - for (Sone sone : webInterface.getCore().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"); @@ -84,6 +78,17 @@ public class LoginPage extends SoneTemplatePage { template.set("identitiesWithoutSone", ownIdentitiesWithoutSone); } + /** + * {@inheritDoc} + */ + @Override + protected String getRedirectTarget(Request request) { + if (getCurrentSone(request.getToadletContext()) != null) { + return "index.html"; + } + return null; + } + // // SONETEMPLATEPAGE METHODS //