remove logout link when authenticated as _anonymous user

This commit is contained in:
Eduard Heimbuch
2019-10-10 14:05:34 +02:00
parent f0311eb138
commit 1162b353db
2 changed files with 4 additions and 5 deletions

View File

@@ -39,7 +39,7 @@ import sonia.scm.user.User;
import sonia.scm.util.ServiceUtil; import sonia.scm.util.ServiceUtil;
/** /**
* The SCMConext searches a implementation of {@link SCMContextProvider} and * The SCMContext searches a implementation of {@link SCMContextProvider} and
* holds a singleton instance of this implementation. * holds a singleton instance of this implementation.
* *
* @author Sebastian Sdorra * @author Sebastian Sdorra

View File

@@ -46,13 +46,12 @@ public class IndexDtoGenerator extends HalAppenderMapper {
} }
if (SecurityUtils.getSubject().isAuthenticated()) { if (SecurityUtils.getSubject().isAuthenticated()) {
builder.single( builder.single(link("me", resourceLinks.me().self()));
link("me", resourceLinks.me().self()),
link("logout", resourceLinks.authentication().logout())
);
if (SecurityUtils.getSubject().getPrincipal().equals(SCMContext.USER_ANONYMOUS)) { if (SecurityUtils.getSubject().getPrincipal().equals(SCMContext.USER_ANONYMOUS)) {
builder.single(link("login", resourceLinks.authentication().jsonLogin())); builder.single(link("login", resourceLinks.authentication().jsonLogin()));
} else {
builder.single(link("logout", resourceLinks.authentication().logout()));
} }
if (PluginPermissions.read().isPermitted()) { if (PluginPermissions.read().isPermitted()) {