Merge pull request #717 from stianst/master
Fixes to JPA user session provider
This commit is contained in:
commit
0f307afd16
2 changed files with 3 additions and 6 deletions
|
@ -103,16 +103,14 @@ public class ClientSessionAdapter implements ClientSessionModel {
|
|||
@Override
|
||||
public void setRoles(Set<String> roles) {
|
||||
if (roles != null) {
|
||||
List<ClientSessionRoleEntity> roleEntities = new LinkedList<ClientSessionRoleEntity>();
|
||||
for (String r : roles) {
|
||||
ClientSessionRoleEntity roleEntity = new ClientSessionRoleEntity();
|
||||
roleEntity.setClientSession(entity);
|
||||
roleEntity.setRoleId(r);
|
||||
em.persist(roleEntity);
|
||||
|
||||
roleEntities.add(roleEntity);
|
||||
entity.getRoles().add(roleEntity);
|
||||
}
|
||||
entity.setRoles(roleEntities);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class JpaUserSessionProvider implements UserSessionProvider {
|
|||
@Override
|
||||
public ClientSessionModel getClientSession(RealmModel realm, String id) {
|
||||
ClientSessionEntity clientSession = em.find(ClientSessionEntity.class, id);
|
||||
if (clientSession != null && clientSession.getSession().getRealmId().equals(realm.getId())) {
|
||||
if (clientSession != null && clientSession.getRealmId().equals(realm.getId())) {
|
||||
return new ClientSessionAdapter(session, em, realm, clientSession);
|
||||
}
|
||||
return null;
|
||||
|
@ -69,8 +69,7 @@ public class JpaUserSessionProvider implements UserSessionProvider {
|
|||
|
||||
@Override
|
||||
public UsernameLoginFailureModel getUserLoginFailure(RealmModel realm, String username) {
|
||||
String id = username + "-" + realm;
|
||||
UsernameLoginFailureEntity entity = em.find(UsernameLoginFailureEntity.class, id);
|
||||
UsernameLoginFailureEntity entity = em.find(UsernameLoginFailureEntity.class, new UsernameLoginFailureEntity.Key(realm.getId(), username));
|
||||
if (entity == null) return null;
|
||||
return new UsernameLoginFailureAdapter(entity);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue