Skip to content

Commit 25ae793

Browse files
committed
pac4j: logout doesn't work with MongoSessionStore fix #759
1 parent 24df466 commit 25ae793

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

jooby-pac4j/src/main/java/org/jooby/internal/pac4j/AuthLogout.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ public void handle(final Request req, final Response rsp) throws Throwable {
4949
// DON'T create a session for JWT/param/header auth (a.k.a stateless)
5050
Optional<Session> ifSession = req.ifSession();
5151
if (ifSession.isPresent()) {
52-
Optional<String> profileId = ifSession.get().unset(Auth.ID).toOptional();
52+
Session session = ifSession.get();
53+
Optional<String> profileId = session.unset(Auth.ID).toOptional();
5354
if (profileId.isPresent()) {
5455
Optional<CommonProfile> profile = req.require(AuthStore.class).unset(profileId.get());
5556
log.debug("logout {}", profile);
57+
session.destroy();
5658
}
5759
} else {
5860
log.debug("nothing to logout from session");

jooby-pac4j/src/test/java/org/jooby/internal/pac4j/AuthLogoutTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void unset() throws Exception {
3131
.expect(unit -> {
3232
Optional<String> id = Optional.of("1");
3333

34-
CommonProfile profile = unit.get(CommonProfile.class);
34+
CommonProfile profile = unit.get(CommonProfile.class);
3535

3636
AuthStore store = unit.get(AuthStore.class);
3737
expect(store.unset("1")).andReturn(Optional.of(profile));
@@ -41,6 +41,7 @@ public void unset() throws Exception {
4141

4242
Session session = unit.get(Session.class);
4343
expect(session.unset(Auth.ID)).andReturn(attr);
44+
session.destroy();
4445
})
4546
.expect(unit -> {
4647
Response rsp = unit.get(Response.class);

0 commit comments

Comments
 (0)