KEYCLOAK-825
Log out user sessions on password reset
This commit is contained in:
parent
e42fe6fb23
commit
e174802b0d
1 changed files with 9 additions and 0 deletions
|
@ -56,6 +56,7 @@ import org.keycloak.services.managers.AppAuthManager;
|
||||||
import org.keycloak.services.managers.Auth;
|
import org.keycloak.services.managers.Auth;
|
||||||
import org.keycloak.services.managers.AuthenticationManager;
|
import org.keycloak.services.managers.AuthenticationManager;
|
||||||
import org.keycloak.services.managers.ClientSessionCode;
|
import org.keycloak.services.managers.ClientSessionCode;
|
||||||
|
import org.keycloak.services.managers.ResourceAdminManager;
|
||||||
import org.keycloak.services.messages.Messages;
|
import org.keycloak.services.messages.Messages;
|
||||||
import org.keycloak.services.resources.flows.Flows;
|
import org.keycloak.services.resources.flows.Flows;
|
||||||
import org.keycloak.services.resources.flows.OAuthRedirect;
|
import org.keycloak.services.resources.flows.OAuthRedirect;
|
||||||
|
@ -624,6 +625,14 @@ public class AccountService {
|
||||||
return account.setError(ape.getMessage()).createResponse(AccountPages.PASSWORD);
|
return account.setError(ape.getMessage()).createResponse(AccountPages.PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<UserSessionModel> sessions = session.sessions().getUserSessions(realm, user);
|
||||||
|
for (UserSessionModel s : sessions) {
|
||||||
|
if (!s.getId().equals(auth.getSession().getId())) {
|
||||||
|
new ResourceAdminManager().logoutSession(uriInfo.getRequestUri(), realm, s);
|
||||||
|
session.sessions().removeUserSession(realm, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
event.event(EventType.UPDATE_PASSWORD).client(auth.getClient()).user(auth.getUser()).success();
|
event.event(EventType.UPDATE_PASSWORD).client(auth.getClient()).user(auth.getUser()).success();
|
||||||
|
|
||||||
setReferrerOnPage();
|
setReferrerOnPage();
|
||||||
|
|
Loading…
Reference in a new issue