From 4a19df92edd7da1b5d1b828a34c72f8e34ec738c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 21 Jan 2011 11:05:16 +0100 Subject: [PATCH] If there is only one local Sone, always be logged in as it. --- src/main/java/net/pterodactylus/sone/web/LogoutPage.java | 2 +- src/main/java/net/pterodactylus/sone/web/WebInterface.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java index 23ccec0..f388368 100644 --- a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java @@ -57,7 +57,7 @@ public class LogoutPage extends SoneTemplatePage { */ @Override public boolean isEnabled(ToadletContext toadletContext) { - return getCurrentSone(toadletContext, false) != null; + return (getCurrentSone(toadletContext, false) != null) && (webInterface.getCore().getLocalSones().size() != 1); } } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 13c7157..0df6d79 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -309,6 +309,10 @@ public class WebInterface implements CoreListener { * currently logged in */ public Sone getCurrentSone(ToadletContext toadletContext, boolean create) { + Set localSones = getCore().getLocalSones(); + if (localSones.size() == 1) { + return localSones.iterator().next(); + } return getCurrentSone(getCurrentSession(toadletContext, create)); } -- 2.7.4