Commits

Sebastian Sdorra committed 876878d

fix logout with enabled anonymous access

Comments (0)

Files changed (1)

scm-webapp/src/main/java/sonia/scm/api/rest/resources/AuthenticationResource.java

 
     Response resp = null;
 
-    // TODO handle anonymous access
+    if (configuration.isAnonymousAccessEnabled())
+    {
 
-    User user = null;
-
-    if (user != null)
-    {
-      ScmState state = createState(subject);
-
-      resp = Response.ok(state).build();
+      resp = Response.ok(createAnonymousState()).build();
     }
     else
     {
     }
     else if (configuration.isAnonymousAccessEnabled())
     {
-      User user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
-                    "scm-anonymous@scm-manager.com");
-      ScmState state = createState(user, Collections.EMPTY_LIST);
 
-      response = Response.ok(state).build();
+      response = Response.ok(createAnonymousState()).build();
     }
     else
     {
    * Method description
    *
    *
+   * @return
+   */
+  private ScmState createAnonymousState()
+  {
+    User user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
+                  "scm-anonymous@scm-manager.com");
+
+    return createState(user, Collections.EMPTY_LIST);
+  }
+
+  /**
+   * Method description
+   *
+   *
    * @param securityContext
    *
    * @param subject