Add: Send ErrorResponse with 'NO_USER_ASSOCIATED' code when no user is associated with the session
This commit is contained in:
+10
-2
@@ -16,7 +16,15 @@ public class LogoutHandler implements CommandHandler<LogoutRequest> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(LogoutRequest request) {
|
public void execute(LogoutRequest request) {
|
||||||
userRegistry.removeBySessionId(request.getSessionId());
|
boolean was_removed = userRegistry.removeBySessionId(request.getSessionId());
|
||||||
responseDispatcher.dispatch(new OkResponse(request.getContext()));
|
if (was_removed) {
|
||||||
|
responseDispatcher.dispatch(new OkResponse(request.getContext()));
|
||||||
|
} else {
|
||||||
|
responseDispatcher.dispatch(
|
||||||
|
new ErrorResponse(
|
||||||
|
request.getContext(),
|
||||||
|
"NO_USER_ASSOCIATED",
|
||||||
|
"No user is associated with your session. Did you login before?"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user