From 6f460add7286d10a6eac5a2e8e4e74af522dbb1b Mon Sep 17 00:00:00 2001 From: Erik Hanson Date: Mon, 16 Dec 2024 10:48:42 -0800 Subject: [PATCH] WIP: More ORCID invitation --- .../AcceptInvitationPageStore.js | 29 +++++++++++++++++++ .../AcceptInvitationUserAccountDetails.vue | 2 +- .../AcceptInvitationVerifyOrcid.vue | 4 +-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/pages/acceptInvitation/AcceptInvitationPageStore.js b/src/pages/acceptInvitation/AcceptInvitationPageStore.js index da74b0c83..741bda7dc 100644 --- a/src/pages/acceptInvitation/AcceptInvitationPageStore.js +++ b/src/pages/acceptInvitation/AcceptInvitationPageStore.js @@ -21,6 +21,7 @@ export const useAcceptInvitationPageStore = defineComponentStore( const email = ref(null); const userId = ref(null); + const existingUser = ref(null); /** All Errors */ const errors = ref({}); @@ -125,6 +126,8 @@ export const useAcceptInvitationPageStore = defineComponentStore( updateAcceptInvitationPayload('username', data.value.username); // add password to invitation payload for validations updateAcceptInvitationPayload('password', null); + + existingUser.value = data.existingUser; errors.value = []; if (steps.value.length === 0) { await submit(); @@ -167,6 +170,30 @@ export const useAcceptInvitationPageStore = defineComponentStore( }); } + const hasValidOrcid = computed(() => { + if (acceptInvitationPayload.value['orcidIsVerified']) { + return true; + } else if (existingUser.value.orcidIsVerified) { + return true; + } + + return false; + }); + + const orcidUri = computed(() => { + const invitationOrcid = acceptInvitationPayload.value['orcid']; + if (invitationOrcid) { + return invitationOrcid; + } + + const userOrcid = existingUser.value['orcid']; + if (userOrcid) { + return userOrcid; + } + + return null; + }); + /** Steps */ const currentStepId = ref( pageInitConfig.steps[0] ? pageInitConfig.steps[0].id : '', @@ -477,6 +504,7 @@ export const useAcceptInvitationPageStore = defineComponentStore( //computed currentStep, currentStepIndex, + hasValidOrcid, isOnFirstStep, isOnLastStep, isValid, @@ -484,6 +512,7 @@ export const useAcceptInvitationPageStore = defineComponentStore( startedSteps, stepTitle, openStep, + orcidUri, steps, pageTitleDescription, errors, diff --git a/src/pages/acceptInvitation/AcceptInvitationUserAccountDetails.vue b/src/pages/acceptInvitation/AcceptInvitationUserAccountDetails.vue index f8ad17a9e..012d2172b 100644 --- a/src/pages/acceptInvitation/AcceptInvitationUserAccountDetails.vue +++ b/src/pages/acceptInvitation/AcceptInvitationUserAccountDetails.vue @@ -61,7 +61,7 @@ const props = defineProps({ validateFields: {type: Array, required: true}, }); const {t} = useLocalize(); -const fields = ref({username: '', password: '', privacyStatement: false}); +const fields = ref({password: '', privacyStatement: false}); const {pageUrl} = useUrl('about/privacy'); const options = [ { diff --git a/src/pages/acceptInvitation/AcceptInvitationVerifyOrcid.vue b/src/pages/acceptInvitation/AcceptInvitationVerifyOrcid.vue index 8edfaff30..c6726d700 100644 --- a/src/pages/acceptInvitation/AcceptInvitationVerifyOrcid.vue +++ b/src/pages/acceptInvitation/AcceptInvitationVerifyOrcid.vue @@ -34,7 +34,7 @@ onMounted(() => { /** * Processes ORCID data for an invitation. * - * @param {Object} data - The ORCID OAuth data object. + * @param {Object|null} data - The ORCID OAuth data object. * @param {string} data.orcid - The ORCID URL of the user. * @param {boolean} data.orcidIsVerified - Indicates if the user's ORCID is verified. * @param {null|string} data.orcidAccessDenied - Indicates if access to ORCID is denied (null if not denied). @@ -54,8 +54,6 @@ async function setOrcidData(data) { * Go to the next step */ function skipOrcid() { - // TODO: See how this should be handled given updated ORCID fields - // delete store.acceptInvitationPayload.orcid; store.openStep(store.steps[1 + store.currentStepIndex].id); }