diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1441c8..1f9dc58 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,9 @@
+This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
# Changelog for "oidc-enrollment-hook"
+## [v1.1.0-SNAPSHOT]
+- Added avatar retrieve/update at every login (#19726)
+
## [v1.0.0-SNAPSHOT]
- First release (#19143) (#19225) (#19226) (#19227) (#19228)
-
-
-This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
\ No newline at end of file
diff --git a/profile.xml b/profile.xml
deleted file mode 100644
index 0fe7047..0000000
--- a/profile.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- Portlet
-
- ${project.description}
- PortletUser
- ${project.artifactId}
- 1.0.0
-
-
- ${project.artifactId}
- ${project.description}
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
-
-
- ${project.build.finalName}.${project.packaging}
-
-
-
-
-
diff --git a/service_archive.xml b/service_archive.xml
deleted file mode 100644
index 7fb882c..0000000
--- a/service_archive.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
- org.apache.maven.plugins
- maven-assembly-plugin
-
-
- descriptor.xml
-
-
-
-
- servicearchive
- install
-
- single
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portal/oidc/lr62/OpenIdConnectAutoLogin.java b/src/main/java/org/gcube/portal/oidc/lr62/OpenIdConnectAutoLogin.java
index 082075c..94badf0 100644
--- a/src/main/java/org/gcube/portal/oidc/lr62/OpenIdConnectAutoLogin.java
+++ b/src/main/java/org/gcube/portal/oidc/lr62/OpenIdConnectAutoLogin.java
@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
import org.gcube.oidc.URLEncodedContextMapper;
import org.gcube.oidc.rest.JWTToken;
+import org.gcube.oidc.rest.OpenIdConnectRESTHelper;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
@@ -21,6 +22,7 @@ import com.liferay.portal.model.User;
import com.liferay.portal.security.auth.BaseAutoLogin;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
+import com.liferay.portal.service.UserServiceUtil;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.PwdGenerator;
@@ -115,6 +117,13 @@ public class OpenIdConnectAutoLogin extends BaseAutoLogin {
if (updateUser) {
UserLocalServiceUtil.updateUser(user);
}
+
+ byte[] userAvatar = OpenIdConnectRESTHelper.getUserAvatar(configuration.getAvatarURL(), token);
+ if (userAvatar != null) {
+ UserServiceUtil.updatePortrait(user.getUserId(), userAvatar);
+ } else {
+ UserServiceUtil.deletePortrait(user.getUserId());
+ }
} catch (SystemException | PortalException e) {
throw new RuntimeException(e);
}
diff --git a/src/test/resources/portal-ext.properties b/src/test/resources/portal-ext.properties
index acefc97..9932c1a 100644
--- a/src/test/resources/portal-ext.properties
+++ b/src/test/resources/portal-ext.properties
@@ -7,3 +7,4 @@ d4science.oidc-scope=openid profile email
d4science.oidc-logout=https://nubis2.int.d4science.net/auth/realms/d4science/protocol/openid-connect/logout
d4science.oidc-logout-on-portal-logout=true
d4science.oidc-create-unexisting-user=true
+d4science.oidc-keycloak_avatar=https://nubis2.int.d4science.net/realms/d4science/avatar-provider/avatar
\ No newline at end of file