remove zenodo from user info
This commit is contained in:
parent
925f195f5a
commit
bd2807fbdf
|
@ -1,13 +1,9 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
||||||
import eu.eudat.exceptions.security.ExpiredTokenException;
|
|
||||||
import eu.eudat.exceptions.security.NonValidTokenException;
|
|
||||||
import eu.eudat.exceptions.security.NullEmailException;
|
|
||||||
import eu.eudat.logic.managers.UserManager;
|
import eu.eudat.logic.managers.UserManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.doi.DOIRequest;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
@ -88,22 +84,6 @@ public class Users extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/registerDOIToken"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<UserProfile>> registerDOIToken(@RequestBody DOIRequest doiRequest, Principal principal) throws NullEmailException, IOException {
|
|
||||||
userManager.registerDOIToken(doiRequest, principal);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/deleteDOIToken"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<UserProfile>> deleteDOIToken(Principal principal) throws NullEmailException, IOException {
|
|
||||||
userManager.deleteDOIToken(principal);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().status(ApiMessageCode.NO_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getCsv"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/getCsv"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity exportCsv(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
ResponseEntity exportCsv(@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||||
|
|
|
@ -24,10 +24,6 @@ public class PrincipalBuilder extends Builder<Principal> {
|
||||||
private String culture;
|
private String culture;
|
||||||
private String language;
|
private String language;
|
||||||
private String timezone;
|
private String timezone;
|
||||||
private String zenodoToken;
|
|
||||||
private Instant zenodoDuration;
|
|
||||||
private String zenodoEmail;
|
|
||||||
private String zenodoRefresh;
|
|
||||||
|
|
||||||
public PrincipalBuilder id(UUID id) {
|
public PrincipalBuilder id(UUID id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -79,25 +75,6 @@ public class PrincipalBuilder extends Builder<Principal> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrincipalBuilder zenodoToken(String zenodoToken) {
|
|
||||||
this.zenodoToken = zenodoToken;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrincipalBuilder zenodoDuration(Instant zenodoDuration) {
|
|
||||||
this.zenodoDuration = zenodoDuration;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrincipalBuilder zenodoEmail(String zenodoEmail) {
|
|
||||||
this.zenodoEmail = zenodoEmail;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrincipalBuilder zenodoRefresh(String zenodoRefresh) {
|
|
||||||
this.zenodoRefresh = zenodoRefresh;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Principal build() {
|
public Principal build() {
|
||||||
|
@ -112,10 +89,6 @@ public class PrincipalBuilder extends Builder<Principal> {
|
||||||
principal.setCulture(culture);
|
principal.setCulture(culture);
|
||||||
principal.setLanguage(language);
|
principal.setLanguage(language);
|
||||||
principal.setTimezone(timezone);
|
principal.setTimezone(timezone);
|
||||||
principal.setZenodoToken(zenodoToken);
|
|
||||||
principal.setZenodoDuration(zenodoDuration);
|
|
||||||
principal.setZenodoEmail(zenodoEmail);
|
|
||||||
principal.setZenodoRefresh(zenodoRefresh);
|
|
||||||
return principal;
|
return principal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,31 +4,25 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.CredentialEntity;
|
import eu.eudat.data.CredentialEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.entities.UserInfoDao;
|
import eu.eudat.data.dao.entities.UserInfoDao;
|
||||||
import eu.eudat.data.entities.*;
|
import eu.eudat.data.entities.DMP;
|
||||||
|
import eu.eudat.data.entities.DescriptionTemplate;
|
||||||
|
import eu.eudat.data.entities.UserInfo;
|
||||||
|
import eu.eudat.data.entities.UserRole;
|
||||||
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem;
|
||||||
import eu.eudat.exceptions.security.NullEmailException;
|
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.builders.entity.UserRoleBuilder;
|
import eu.eudat.logic.builders.entity.UserRoleBuilder;
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||||
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoAccessType;
|
|
||||||
import eu.eudat.logic.security.customproviders.Zenodo.ZenodoCustomProvider;
|
|
||||||
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
|
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
import eu.eudat.models.HintedModelFactory;
|
import eu.eudat.models.HintedModelFactory;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.data.doi.DOIRequest;
|
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.login.Credentials;
|
|
||||||
import eu.eudat.models.data.principal.PrincipalModel;
|
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.models.data.userinfo.UserCredential;
|
import eu.eudat.models.data.userinfo.UserCredential;
|
||||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
import eu.eudat.models.data.userinfo.UserProfile;
|
import eu.eudat.models.data.userinfo.UserProfile;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.types.Authorities;
|
import eu.eudat.types.Authorities;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -42,14 +36,8 @@ import org.springframework.stereotype.Component;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -58,13 +46,11 @@ public class UserManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(UserManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(UserManager.class);
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
private ZenodoCustomProvider zenodoCustomProvider;
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UserManager(ApiContext apiContext, ZenodoCustomProvider zenodoCustomProvider, Environment environment) {
|
public UserManager(ApiContext apiContext, Environment environment) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.zenodoCustomProvider = zenodoCustomProvider;
|
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,27 +134,6 @@ public class UserManager {
|
||||||
return dataTableData;
|
return dataTableData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerDOIToken(DOIRequest doiRequest, Principal principal) throws IOException { //TODO: Authn
|
|
||||||
ZenodoResponseToken responseToken = this.zenodoCustomProvider.getAccessToken(ZenodoAccessType.AUTHORIZATION_CODE,
|
|
||||||
doiRequest.getZenodoRequest().getCode(), this.environment.getProperty("zenodo.login.client_id"),
|
|
||||||
this.environment.getProperty("zenodo.login.client_secret"), doiRequest.getRedirectUri());
|
|
||||||
Map<String, Object> settings = new HashMap<>();
|
|
||||||
settings.put("zenodoEmail", responseToken.getEmail());
|
|
||||||
settings.put("zenodoRefresh", responseToken.getRefreshToken());
|
|
||||||
settings.put("zenodoToken", responseToken.getAccessToken());
|
|
||||||
settings.put("expirationDate", Instant.now().plusSeconds(responseToken.getExpiresIn()).toEpochMilli());
|
|
||||||
this.updateSettings(settings, principal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteDOIToken(Principal principal) throws IOException {
|
|
||||||
Map<String, Object> settings = new HashMap<>();
|
|
||||||
settings.put("zenodoEmail", "");
|
|
||||||
settings.put("zenodoRefresh", "");
|
|
||||||
settings.put("zenodoToken", "");
|
|
||||||
settings.put("expirationDate", 0);
|
|
||||||
this.updateSettings(settings, principal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResponseEntity<byte[]> exportToCsv(Principal principal) throws IOException {
|
public ResponseEntity<byte[]> exportToCsv(Principal principal) throws IOException {
|
||||||
if (!principal.getAuthz().contains(Authorities.ADMIN))
|
if (!principal.getAuthz().contains(Authorities.ADMIN))
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package eu.eudat.logic.security.customproviders.Zenodo;
|
|
||||||
|
|
||||||
public enum ZenodoAccessType {
|
|
||||||
AUTHORIZATION_CODE("authorization_code", "code"),
|
|
||||||
REFRESH_TOKEN("refresh_token", "refresh_token");
|
|
||||||
|
|
||||||
private final String grantType;
|
|
||||||
private final String property;
|
|
||||||
|
|
||||||
ZenodoAccessType(String grantType, String property) {
|
|
||||||
this.grantType = grantType;
|
|
||||||
this.property = property;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGrantType() {
|
|
||||||
return grantType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperty() {
|
|
||||||
return property;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package eu.eudat.logic.security.customproviders.Zenodo;
|
|
||||||
|
|
||||||
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
|
|
||||||
|
|
||||||
public interface ZenodoCustomProvider {
|
|
||||||
ZenodoResponseToken getAccessToken(ZenodoAccessType accessType, String code, String clientId, String clientSecret, String redirectUri);
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package eu.eudat.logic.security.customproviders.Zenodo;
|
|
||||||
|
|
||||||
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoResponseToken;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
|
||||||
import org.springframework.util.MultiValueMap;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component("ZenodoCustomProvider")
|
|
||||||
public class ZenodoCustomProviderImpl implements ZenodoCustomProvider {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ZenodoCustomProviderImpl.class);
|
|
||||||
|
|
||||||
private Environment environment;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public ZenodoCustomProviderImpl(Environment environment) {
|
|
||||||
this.environment = environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ZenodoResponseToken getAccessToken(ZenodoAccessType accessType, String code, String clientId, String clientSecret, String redirectUri) {
|
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
|
||||||
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
|
||||||
|
|
||||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
|
||||||
map.add("client_id", clientId);
|
|
||||||
map.add("client_secret", clientSecret);
|
|
||||||
map.add("grant_type", accessType.getGrantType());
|
|
||||||
map.add(accessType.getProperty(), code);
|
|
||||||
map.add("redirect_uri", redirectUri);
|
|
||||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String, Object> values = restTemplate.postForObject(this.environment.getProperty("zenodo.login.access_token_url"), request, Map.class);
|
|
||||||
ZenodoResponseToken zenodoResponseToken = new ZenodoResponseToken();
|
|
||||||
Map<String, Object> user = (Map<String, Object>) values.get("user");
|
|
||||||
zenodoResponseToken.setUserId((String) user.get("id"));
|
|
||||||
zenodoResponseToken.setEmail((String) user.get("email"));
|
|
||||||
zenodoResponseToken.setExpiresIn((Integer) values.get("expires_in"));
|
|
||||||
zenodoResponseToken.setAccessToken((String) values.get("access_token"));
|
|
||||||
zenodoResponseToken.setRefreshToken((String) values.get("refresh_token"));
|
|
||||||
|
|
||||||
return zenodoResponseToken;
|
|
||||||
} catch (HttpClientErrorException ex) {
|
|
||||||
logger.error(ex.getResponseBodyAsString(), ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpHeaders createBearerAuthHeaders(String accessToken) {
|
|
||||||
return new HttpHeaders() {{
|
|
||||||
String authHeader = "Bearer " + accessToken;
|
|
||||||
set("Authorization", authHeader);
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package eu.eudat.logic.security.customproviders.Zenodo;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ZenodoUser {
|
|
||||||
private String userId;
|
|
||||||
private String email;
|
|
||||||
private String accessToken;
|
|
||||||
private Integer expiresIn;
|
|
||||||
private String refreshToken;
|
|
||||||
|
|
||||||
public String getUserId() {
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserId(String userId) {
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessToken() {
|
|
||||||
return accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccessToken(String accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getExpiresIn() {
|
|
||||||
return expiresIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpiresIn(Integer expiresIn) {
|
|
||||||
this.expiresIn = expiresIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefreshToken() {
|
|
||||||
return refreshToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefreshToken(String refreshToken) {
|
|
||||||
this.refreshToken = refreshToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZenodoUser getZenodoUser(Object data) {
|
|
||||||
this.userId = (String) ((Map) data).get("userId");
|
|
||||||
this.email = (String) ((Map) data).get("email");
|
|
||||||
this.accessToken = (String) ((Map) data).get("accessToken");
|
|
||||||
this.expiresIn = (Integer) ((Map) data).get("expiresIn");
|
|
||||||
this.refreshToken = (String) ((Map) data).get("refreshToken");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package eu.eudat.logic.security.validators.zenodo.helpers;
|
|
||||||
|
|
||||||
public class ZenodoRequest {
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
public void setCode(String code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package eu.eudat.logic.security.validators.zenodo.helpers;
|
|
||||||
|
|
||||||
public class ZenodoResponseToken {
|
|
||||||
private String userId;
|
|
||||||
private String email;
|
|
||||||
private Integer expiresIn;
|
|
||||||
private String accessToken;
|
|
||||||
private String refreshToken;
|
|
||||||
|
|
||||||
public String getUserId() {
|
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
public void setUserId(String userId) {
|
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getExpiresIn() {
|
|
||||||
return expiresIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExpiresIn(Integer expiresIn) {
|
|
||||||
this.expiresIn = expiresIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessToken() {
|
|
||||||
return accessToken;
|
|
||||||
}
|
|
||||||
public void setAccessToken(String accessToken) {
|
|
||||||
this.accessToken = accessToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefreshToken() {
|
|
||||||
return refreshToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRefreshToken(String refreshToken) {
|
|
||||||
this.refreshToken = refreshToken;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -49,10 +49,6 @@ public class NonVerifiedUserEmailAuthenticationService extends AbstractAuthentic
|
||||||
.culture("")
|
.culture("")
|
||||||
.language("")
|
.language("")
|
||||||
.timezone("")
|
.timezone("")
|
||||||
.zenodoToken("")
|
|
||||||
.zenodoDuration(Instant.now())
|
|
||||||
.zenodoEmail("")
|
|
||||||
.zenodoRefresh("")
|
|
||||||
.build();
|
.build();
|
||||||
principalItem.setAuthorities(new HashSet<>());
|
principalItem.setAuthorities(new HashSet<>());
|
||||||
principalItem.getAuthz().add(Authorities.USER);
|
principalItem.getAuthz().add(Authorities.USER);
|
||||||
|
|
|
@ -38,30 +38,6 @@ public class VerifiedUserAuthenticationService extends AbstractAuthenticationSer
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
avatarUrl = "";
|
avatarUrl = "";
|
||||||
}
|
}
|
||||||
String zenodoToken;
|
|
||||||
try {
|
|
||||||
zenodoToken = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoToken").asText() : "";
|
|
||||||
} catch (Exception e) {
|
|
||||||
zenodoToken = "";
|
|
||||||
}
|
|
||||||
Instant zenodoDuration;
|
|
||||||
try {
|
|
||||||
zenodoDuration = user.getAdditionalinfo() != null ? Instant.ofEpochMilli(new ObjectMapper().readTree(user.getAdditionalinfo()).get("expirationDate").asLong()) : Instant.now();
|
|
||||||
} catch (Exception e) {
|
|
||||||
zenodoDuration = Instant.now();
|
|
||||||
}
|
|
||||||
String zenodoEmail;
|
|
||||||
try {
|
|
||||||
zenodoEmail = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoEmail").asText() : "";
|
|
||||||
} catch (Exception e) {
|
|
||||||
zenodoEmail = "";
|
|
||||||
}
|
|
||||||
String zenodoRefresh;
|
|
||||||
try {
|
|
||||||
zenodoRefresh = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("zenodoRefresh").asText() : "";
|
|
||||||
} catch (Exception e) {
|
|
||||||
zenodoRefresh = "";
|
|
||||||
}
|
|
||||||
String culture;
|
String culture;
|
||||||
try {
|
try {
|
||||||
culture = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("culture").get("name").asText() : "";
|
culture = user.getAdditionalinfo() != null ? new ObjectMapper().readTree(user.getAdditionalinfo()).get("culture").get("name").asText() : "";
|
||||||
|
@ -89,10 +65,6 @@ public class VerifiedUserAuthenticationService extends AbstractAuthenticationSer
|
||||||
.culture(culture)
|
.culture(culture)
|
||||||
.language(language)
|
.language(language)
|
||||||
.timezone(timezone)
|
.timezone(timezone)
|
||||||
.zenodoToken(zenodoToken)
|
|
||||||
.zenodoDuration(zenodoDuration)
|
|
||||||
.zenodoEmail(zenodoEmail)
|
|
||||||
.zenodoRefresh(zenodoRefresh)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<UserRole> userRoles = apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().getUserRoles(user);
|
List<UserRole> userRoles = apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().getUserRoles(user);
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package eu.eudat.models.data.doi;
|
|
||||||
|
|
||||||
import eu.eudat.logic.security.validators.zenodo.helpers.ZenodoRequest;
|
|
||||||
|
|
||||||
public class DOIRequest {
|
|
||||||
|
|
||||||
private ZenodoRequest zenodoRequest;
|
|
||||||
private String redirectUri;
|
|
||||||
|
|
||||||
public ZenodoRequest getZenodoRequest() {
|
|
||||||
return zenodoRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoRequest(ZenodoRequest zenodoRequest) {
|
|
||||||
this.zenodoRequest = zenodoRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRedirectUri() {
|
|
||||||
return redirectUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRedirectUri(String redirectUri) {
|
|
||||||
this.redirectUri = redirectUri;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,9 +8,6 @@ public class LoginProviderUser {
|
||||||
private String secret;
|
private String secret;
|
||||||
private String avatarUrl;
|
private String avatarUrl;
|
||||||
private boolean isVerified;
|
private boolean isVerified;
|
||||||
private String zenodoId;
|
|
||||||
private Integer zenodoExpire;
|
|
||||||
private String zenodoRefresh;
|
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -59,28 +56,4 @@ public class LoginProviderUser {
|
||||||
public void setAvatarUrl(String avatarUrl) {
|
public void setAvatarUrl(String avatarUrl) {
|
||||||
this.avatarUrl = avatarUrl;
|
this.avatarUrl = avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getZenodoId() {
|
|
||||||
return zenodoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoId(String zenodoId) {
|
|
||||||
this.zenodoId = zenodoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getZenodoExpire() {
|
|
||||||
return zenodoExpire;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoExpire(Integer zenodoExpire) {
|
|
||||||
this.zenodoExpire = zenodoExpire;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getZenodoRefresh() {
|
|
||||||
return zenodoRefresh;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoRefresh(String zenodoRefresh) {
|
|
||||||
this.zenodoRefresh = zenodoRefresh;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ public class PrincipalModel {
|
||||||
private String culture;
|
private String culture;
|
||||||
private String language;
|
private String language;
|
||||||
private String timezone;
|
private String timezone;
|
||||||
private String zenodoEmail;
|
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -105,14 +104,6 @@ public class PrincipalModel {
|
||||||
this.timezone = timezone;
|
this.timezone = timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getZenodoEmail() {
|
|
||||||
return zenodoEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoEmail(String zenodoEmail) {
|
|
||||||
this.zenodoEmail = zenodoEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PrincipalModel fromEntity(Principal principal) {
|
public static PrincipalModel fromEntity(Principal principal) {
|
||||||
PrincipalModel model = new PrincipalModel();
|
PrincipalModel model = new PrincipalModel();
|
||||||
model.setId(principal.getId());
|
model.setId(principal.getId());
|
||||||
|
@ -125,7 +116,6 @@ public class PrincipalModel {
|
||||||
model.setLanguage(principal.getLanguage());
|
model.setLanguage(principal.getLanguage());
|
||||||
model.setName(principal.getName());
|
model.setName(principal.getName());
|
||||||
model.setTimezone(principal.getTimezone());
|
model.setTimezone(principal.getTimezone());
|
||||||
model.setZenodoEmail(principal.getZenodoEmail());
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,6 @@ public class Principal {
|
||||||
private String culture;
|
private String culture;
|
||||||
private String language;
|
private String language;
|
||||||
private String timezone;
|
private String timezone;
|
||||||
private String zenodoToken;
|
|
||||||
private Instant zenodoDuration;
|
|
||||||
private String zenodoRefresh;
|
|
||||||
private String zenodoEmail;
|
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -100,38 +96,6 @@ public class Principal {
|
||||||
this.timezone = timezone;
|
this.timezone = timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getZenodoToken() {
|
|
||||||
return zenodoToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoToken(String zenodoToken) {
|
|
||||||
this.zenodoToken = zenodoToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getZenodoDuration() {
|
|
||||||
return zenodoDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoDuration(Instant zenodoDuration) {
|
|
||||||
this.zenodoDuration = zenodoDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getZenodoRefresh() {
|
|
||||||
return zenodoRefresh;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoRefresh(String zenodoRefresh) {
|
|
||||||
this.zenodoRefresh = zenodoRefresh;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getZenodoEmail() {
|
|
||||||
return zenodoEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoEmail(String zenodoEmail) {
|
|
||||||
this.zenodoEmail = zenodoEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public Set<Authorities> getAuthz() {
|
public Set<Authorities> getAuthz() {
|
||||||
return this.authorities;
|
return this.authorities;
|
||||||
|
|
|
@ -28,7 +28,6 @@ public class UserProfile implements DataModel<eu.eudat.data.entities.UserInfo, U
|
||||||
private Date lastloggedin;
|
private Date lastloggedin;
|
||||||
//private String additionalinfo;
|
//private String additionalinfo;
|
||||||
private List<DataManagementPlan> associatedDmps;
|
private List<DataManagementPlan> associatedDmps;
|
||||||
private String zenodoEmail;
|
|
||||||
private Map<String, Object> language;
|
private Map<String, Object> language;
|
||||||
private String timezone;
|
private String timezone;
|
||||||
private Map<String, Object> culture;
|
private Map<String, Object> culture;
|
||||||
|
@ -92,13 +91,6 @@ public class UserProfile implements DataModel<eu.eudat.data.entities.UserInfo, U
|
||||||
this.associatedDmps = associatedDmps;
|
this.associatedDmps = associatedDmps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getZenodoEmail() {
|
|
||||||
return zenodoEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZenodoEmail(String zenodoEmail) {
|
|
||||||
this.zenodoEmail = zenodoEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> getLanguage() {
|
public Map<String, Object> getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
|
@ -163,7 +155,6 @@ public class UserProfile implements DataModel<eu.eudat.data.entities.UserInfo, U
|
||||||
this.language = (Map)additionalInfo.get("language");
|
this.language = (Map)additionalInfo.get("language");
|
||||||
this.culture = (Map) additionalInfo.get("culture");
|
this.culture = (Map) additionalInfo.get("culture");
|
||||||
this.timezone = (String) additionalInfo.get("timezone");
|
this.timezone = (String) additionalInfo.get("timezone");
|
||||||
this.zenodoEmail = (String) additionalInfo.get("zenodoEmail");
|
|
||||||
this.avatarUrl = (String) additionalInfo.get("avatarUrl");
|
this.avatarUrl = (String) additionalInfo.get("avatarUrl");
|
||||||
this.organization = Organisation.fromMap((HashMap<String, Object>) additionalInfo.get("organization"));
|
this.organization = Organisation.fromMap((HashMap<String, Object>) additionalInfo.get("organization"));
|
||||||
this.roleOrganization = (String) additionalInfo.get("roleOrganization");
|
this.roleOrganization = (String) additionalInfo.get("roleOrganization");
|
||||||
|
|
|
@ -18,12 +18,3 @@ web:
|
||||||
jwt:
|
jwt:
|
||||||
claims: [ role, x-role ]
|
claims: [ role, x-role ]
|
||||||
issuer-uri: ${IDP_ISSUER_URI:}
|
issuer-uri: ${IDP_ISSUER_URI:}
|
||||||
|
|
||||||
zenodo:
|
|
||||||
affiliation: ARGOS
|
|
||||||
community: argos
|
|
||||||
login:
|
|
||||||
access_token_url: ${ZENODO_ACCESS_TOKEN_URL:}
|
|
||||||
client_id: ${ZENODO_CLIENT_ID:}
|
|
||||||
client_secret: ${ZENODO_CLIENT_SECRET:}
|
|
||||||
redirect_uri: http://localhost:4200/login/external/zenodo
|
|
|
@ -248,14 +248,6 @@ const appRoutes: Routes = [
|
||||||
{ path: 'logout', loadChildren: () => import('./ui/auth/logout/logout.module').then(m => m.LogoutModule) },
|
{ path: 'logout', loadChildren: () => import('./ui/auth/logout/logout.module').then(m => m.LogoutModule) },
|
||||||
{ path: 'reload', component: ReloadHelperComponent },
|
{ path: 'reload', component: ReloadHelperComponent },
|
||||||
{ path: 'oauth2', component: Oauth2DialogComponent },
|
{ path: 'oauth2', component: Oauth2DialogComponent },
|
||||||
{
|
|
||||||
path: 'external',
|
|
||||||
loadChildren: () => import('./ui/external/external.module').then(m => m.ExternalModule),
|
|
||||||
data: {
|
|
||||||
breadcrumb: true,
|
|
||||||
|
|
||||||
},
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
import { AuthProvider } from "../../common/enum/auth-provider";
|
|
||||||
|
|
||||||
export interface LoginInfo {
|
|
||||||
ticket: string;
|
|
||||||
provider: AuthProvider;
|
|
||||||
data?: any;
|
|
||||||
}
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { KeycloakFlow } from 'keycloak-js';
|
import { KeycloakFlow } from 'keycloak-js';
|
||||||
import { LoginConfiguration } from './login-configuration.model';
|
|
||||||
|
|
||||||
export class KeycloakConfiguration {
|
export class KeycloakConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
export class LoginConfiguration {
|
|
||||||
|
|
||||||
private _clientId: string;
|
|
||||||
get clientId(): string {
|
|
||||||
return this._clientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _oauthUrl: string;
|
|
||||||
get oauthUrl(): string {
|
|
||||||
return this._oauthUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _redirectUri: string;
|
|
||||||
get redirectUri(): string {
|
|
||||||
return this._redirectUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
private _state: string;
|
|
||||||
get state(): string {
|
|
||||||
return this._state;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,7 +11,6 @@ export interface UserListingModel {
|
||||||
language: any;
|
language: any;
|
||||||
culture: any;
|
culture: any;
|
||||||
timezone: String;
|
timezone: String;
|
||||||
zenodoEmail: String;
|
|
||||||
avatarUrl: String;
|
avatarUrl: String;
|
||||||
organization: OrganizationModel;
|
organization: OrganizationModel;
|
||||||
roleOrganization: RoleOrganizationType;
|
roleOrganization: RoleOrganizationType;
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
export class ZenodoToken {
|
|
||||||
userId: string;
|
|
||||||
expiresIn: number;
|
|
||||||
accessToken:string;
|
|
||||||
email: string;
|
|
||||||
refreshToken: string;
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import { HelpService } from '@app/core/model/configuration-models/help-service.m
|
||||||
import { Logging } from '@app/core/model/configuration-models/logging.model';
|
import { Logging } from '@app/core/model/configuration-models/logging.model';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { KeycloakConfiguration } from '@app/core/model/configuration-models/keycloak-configuration.model';
|
import { KeycloakConfiguration } from '@app/core/model/configuration-models/keycloak-configuration.model';
|
||||||
import { LoginConfiguration } from '@app/core/model/configuration-models/login-configuration.model';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
@ -137,10 +136,6 @@ export class ConfigurationService extends BaseComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _zenodoConfiguration: LoginConfiguration;
|
|
||||||
get zenodoConfiguration(): LoginConfiguration {
|
|
||||||
return this._zenodoConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private parseResponse(config: any) {
|
private parseResponse(config: any) {
|
||||||
|
@ -150,7 +145,6 @@ export class ConfigurationService extends BaseComponent {
|
||||||
this._defaultCulture = config.defaultCulture;
|
this._defaultCulture = config.defaultCulture;
|
||||||
this._defaultLanguage = config.defaultLanguage;
|
this._defaultLanguage = config.defaultLanguage;
|
||||||
this._availableLanguages = config.availableLanguages;
|
this._availableLanguages = config.availableLanguages;
|
||||||
this._zenodoConfiguration = config.zenodoConfiguration;
|
|
||||||
this._keycloak = KeycloakConfiguration.parseValue(config.keycloak);
|
this._keycloak = KeycloakConfiguration.parseValue(config.keycloak);
|
||||||
this._logging = Logging.parseValue(config.logging);
|
this._logging = Logging.parseValue(config.logging);
|
||||||
this._lockInterval = config.lockInterval;
|
this._lockInterval = config.lockInterval;
|
||||||
|
|
|
@ -57,16 +57,6 @@ export class UserService {
|
||||||
return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers});
|
return this.http.post<UserListingModel>(this.actionUrl + 'find', email, {headers: this.headers});
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerDOIToken(code: string, redirectUri: string): Observable<any> {
|
|
||||||
const url = this.actionUrl + 'registerDOIToken';
|
|
||||||
return this.http.post(url, {zenodoRequest: {code: code}, redirectUri: redirectUri}, { headers: this.headers });
|
|
||||||
}
|
|
||||||
|
|
||||||
public deleteDOIToken(): Observable<any> {
|
|
||||||
const url = this.actionUrl + 'deleteDOIToken';
|
|
||||||
return this.http.delete(url, { headers: this.headers });
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadCSV(): Observable<HttpResponse<Blob>> {
|
downloadCSV(): Observable<HttpResponse<Blob>> {
|
||||||
let headerCsv: HttpHeaders = this.headers.set('Content-Type', 'application/csv')
|
let headerCsv: HttpHeaders = this.headers.set('Content-Type', 'application/csv')
|
||||||
return this.httpClient.get(this.actionUrl + 'getCsv/', { responseType: 'blob', observe: 'response', headers: headerCsv });
|
return this.httpClient.get(this.actionUrl + 'getCsv/', { responseType: 'blob', observe: 'response', headers: headerCsv });
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
import { ZenodoComponent } from './zenodo/zenodo.component';
|
|
||||||
import { ExternalRoutingModule } from './external.routing';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [ZenodoComponent],
|
|
||||||
imports: [
|
|
||||||
CommonModule,
|
|
||||||
ExternalRoutingModule
|
|
||||||
]
|
|
||||||
})
|
|
||||||
export class ExternalModule { }
|
|
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
import { Routes, RouterModule } from '@angular/router';
|
|
||||||
import { ZenodoComponent } from './zenodo/zenodo.component';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const routes: Routes = [
|
|
||||||
{
|
|
||||||
path: '',
|
|
||||||
component: ZenodoComponent,
|
|
||||||
data: {
|
|
||||||
breadcrumb: true
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'zenodo/:id',
|
|
||||||
component: ZenodoComponent,
|
|
||||||
data: {
|
|
||||||
breadcrumb: true
|
|
||||||
},
|
|
||||||
},];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [RouterModule.forChild(routes)],
|
|
||||||
exports: [RouterModule]
|
|
||||||
})
|
|
||||||
|
|
||||||
export class ExternalRoutingModule { }
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
|
||||||
import { ActivatedRoute, Router, Params } from '@angular/router';
|
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
|
||||||
import { takeUntil } from 'rxjs/operators';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-zenodo',
|
|
||||||
templateUrl: './zenodo.component.html',
|
|
||||||
styleUrls: ['./zenodo.component.scss']
|
|
||||||
})
|
|
||||||
export class ZenodoComponent extends BaseComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private route: ActivatedRoute,
|
|
||||||
private router: Router, ) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((params: Params) => {
|
|
||||||
const id = params.params.id;
|
|
||||||
this.router.navigate([`/explore-plans/publicOverview/${id}`]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -184,28 +184,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Zenodo -->
|
|
||||||
<div class="row mb">
|
|
||||||
<div class="col">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-auto field-title">{{ 'USER-PROFILE.ZENODO.TITLE' | translate}}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div *ngIf="hasZenodo()" class="col-auto language-form d-flex">
|
|
||||||
<mat-form-field>
|
|
||||||
<input type="text" placeholder="{{'USER-PROFILE.SETTINGS.ZENODO' | translate}}" value="{{zenodoEmail}}" matInput disabled>
|
|
||||||
<mat-hint>{{'USER-PROFILE.ZENODO.DESCRIPTION' | translate}}</mat-hint>
|
|
||||||
</mat-form-field>
|
|
||||||
<div *ngIf="hasZenodo()" class="col-auto d-flex">
|
|
||||||
<div class="remove-btn"><button mat-raised-button type="button" (click)="RemoveZenodo()" class="confirm unlinkBtn">{{'USER-PROFILE.ZENODO.LOGOUT' | translate}}</button></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="!hasZenodo()" class="col-md-4 link-zenodo-btn">
|
|
||||||
<div><button mat-raised-button type="button" (click)="loginToZenodo()" class="confirm accent-btn mt-3">{{'USER-PROFILE.ZENODO.AUTHORIZE' | translate}}</button></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row d-flex mb-5">
|
<div class="row d-flex mb-5">
|
||||||
<div class="col-auto ml-auto"><button mat-raised-button class="save-btn" type="button" (click)="save()">{{'USER-PROFILE.ACTIONS.SAVE' | translate}}</button></div>
|
<div class="col-auto ml-auto"><button mat-raised-button class="save-btn" type="button" (click)="save()">{{'USER-PROFILE.ACTIONS.SAVE' | translate}}</button></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,8 +13,6 @@ import * as moment from 'moment-timezone';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
import { LanguageService } from '@app/core/services/language/language.service';
|
import { LanguageService } from '@app/core/services/language/language.service';
|
||||||
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
|
|
||||||
import { Oauth2DialogService } from '../misc/oauth2-dialog/service/oauth2-dialog.service';
|
|
||||||
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
|
||||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||||
import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item';
|
import { ExternalSourceItemModel } from '@app/core/model/external-sources/external-source-item';
|
||||||
|
@ -51,8 +49,6 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
timezones: Observable<any[]>;
|
timezones: Observable<any[]>;
|
||||||
editMode = false;
|
editMode = false;
|
||||||
languages = [];
|
languages = [];
|
||||||
zenodoToken: string;
|
|
||||||
zenodoEmail: String;
|
|
||||||
roleOrganizationEnum = RoleOrganizationType;
|
roleOrganizationEnum = RoleOrganizationType;
|
||||||
authProviderEnum = AuthProvider;
|
authProviderEnum = AuthProvider;
|
||||||
private oauthLock: boolean;
|
private oauthLock: boolean;
|
||||||
|
@ -80,7 +76,6 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
private authentication: AuthService,
|
private authentication: AuthService,
|
||||||
private languageService: LanguageService,
|
private languageService: LanguageService,
|
||||||
private configurationService: ConfigurationService,
|
private configurationService: ConfigurationService,
|
||||||
private oauth2DialogService: Oauth2DialogService,
|
|
||||||
private uiNotificationService: UiNotificationService,
|
private uiNotificationService: UiNotificationService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
|
@ -102,8 +97,6 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
const userId = !params['id'] ? 'me' : params['id'];
|
const userId = !params['id'] ? 'me' : params['id'];
|
||||||
this.user = this.userService.getUser(userId).pipe(map(result => {
|
this.user = this.userService.getUser(userId).pipe(map(result => {
|
||||||
//result['additionalinfo'] = JSON.parse(result['additionalinfo']);
|
//result['additionalinfo'] = JSON.parse(result['additionalinfo']);
|
||||||
//this.zenodoToken = result['additionalinfo']['zenodoToken'];
|
|
||||||
this.zenodoEmail = result['zenodoEmail'];
|
|
||||||
|
|
||||||
this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result);
|
this.userProfileEditorModel = new UserProfileEditorModel().fromModel(result);
|
||||||
this.formGroup = this.userProfileEditorModel.buildForm(this.configurationService.availableLanguages);
|
this.formGroup = this.userProfileEditorModel.buildForm(this.configurationService.availableLanguages);
|
||||||
|
@ -258,46 +251,6 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
|
||||||
(ev.target as HTMLImageElement).src = 'assets/images/profile-placeholder.png';
|
(ev.target as HTMLImageElement).src = 'assets/images/profile-placeholder.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
public hasZenodo(): boolean {
|
|
||||||
return !isNullOrUndefined(this.zenodoEmail) && this.zenodoEmail !== "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public loginToZenodo() {
|
|
||||||
this.showOauth2Dialog(this.getAccessUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
getAccessUrl(): string {
|
|
||||||
const redirectUri = this.configurationService.app + 'oauth2';
|
|
||||||
const url = this.configurationService.zenodoConfiguration.oauthUrl
|
|
||||||
+ '?client_id=' + this.configurationService.zenodoConfiguration.clientId
|
|
||||||
+ '&response_type=code&scope=deposit:write+deposit:actions+user:email&state=astate&redirect_uri='
|
|
||||||
+ redirectUri;
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
showOauth2Dialog(url: string) {
|
|
||||||
this.oauth2DialogService.login(url)
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
if (result !== undefined) {
|
|
||||||
if (result.oauthCode !== undefined && result.oauthCode !== null && !this.oauthLock) {
|
|
||||||
this.userService.registerDOIToken(result.oauthCode, this.configurationService.app + 'oauth2')
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(() => this.router.navigate(['/reload']).then(() => this.router.navigate(['/profile'])));
|
|
||||||
this.oauthLock = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.oauthLock = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public RemoveZenodo() {
|
|
||||||
this.userService.deleteDOIToken()
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(() => this.router.navigate(['/reload']).then(() => this.router.navigate(['/profile'])));
|
|
||||||
}
|
|
||||||
|
|
||||||
public removeAccount(userCredential :UserCredentialModel) {
|
public removeAccount(userCredential :UserCredentialModel) {
|
||||||
this.dialog.open(ConfirmationDialogComponent, {
|
this.dialog.open(ConfirmationDialogComponent, {
|
||||||
data:{
|
data:{
|
||||||
|
|
Loading…
Reference in New Issue