Skip to content

Commit

Permalink
logged out user
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdurin committed Jan 15, 2024
1 parent b1ec30c commit 1db4c11
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import org.springframework.cloud.gateway.route.Route;
import org.springframework.core.Ordered;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.server.DefaultServerRedirectStrategy;
import org.springframework.security.web.server.ServerRedirectStrategy;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebSession;

import lombok.NonNull;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -97,8 +99,10 @@ public class ResolveGeorchestraUserGlobalFilter implements GlobalFilter, Ordered
})//
.map(user -> {
if (user.isEmpty()) {
return this.redirectStrategy.sendRedirect(exchange, URI
.create("https://georchestra-127-0-1-1.traefik.me/login?error=" + DUPLICATE_ACCOUNT));
SecurityContextHolder.getContext();
return this.redirectStrategy //
.sendRedirect(exchange, URI.create("/login?error=" + DUPLICATE_ACCOUNT)) //
.then(exchange.getSession().flatMap(WebSession::invalidate));
}

GeorchestraUser usr = user.orElse(null);
Expand All @@ -110,8 +114,8 @@ public class ResolveGeorchestraUserGlobalFilter implements GlobalFilter, Ordered
}
return chain.filter(exchange);
})//
.defaultIfEmpty(chain.filter(exchange))//
.flatMap(Function.identity());
.flatMap(Function.identity()) //
.switchIfEmpty(Mono.fromRunnable(() -> chain.filter(exchange)));

System.out.println(res);
return res;
Expand Down

0 comments on commit 1db4c11

Please sign in to comment.