Skip to content

Commit

Permalink
WIP: More ORCID invitation
Browse files Browse the repository at this point in the history
  • Loading branch information
ewhanson committed Dec 16, 2024
1 parent 3028bc5 commit 6f460ad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
29 changes: 29 additions & 0 deletions src/pages/acceptInvitation/AcceptInvitationPageStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({});
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 : '',
Expand Down Expand Up @@ -477,13 +504,15 @@ export const useAcceptInvitationPageStore = defineComponentStore(
//computed
currentStep,
currentStepIndex,
hasValidOrcid,
isOnFirstStep,
isOnLastStep,
isValid,
pageTitle,
startedSteps,
stepTitle,
openStep,
orcidUri,
steps,
pageTitleDescription,
errors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
4 changes: 1 addition & 3 deletions src/pages/acceptInvitation/AcceptInvitationVerifyOrcid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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);
}
Expand Down

0 comments on commit 6f460ad

Please sign in to comment.