forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix: entity-type identifier validation
- Ensure claims contain only correct and necessary giver and recipient identifiers, as per Endorser.ch documentation
This commit is contained in:
@@ -417,21 +417,7 @@
|
|||||||
<router-link
|
<router-link
|
||||||
:to="{
|
:to="{
|
||||||
name: 'gifted-details',
|
name: 'gifted-details',
|
||||||
query: {
|
query: giftedDetailsQuery,
|
||||||
amountInput,
|
|
||||||
description,
|
|
||||||
giverDid: showProjects ? undefined : giver?.did,
|
|
||||||
giverName: giver?.name,
|
|
||||||
offerId,
|
|
||||||
fulfillsProjectId:
|
|
||||||
showProjects && isFromProjectView
|
|
||||||
? giver?.handleId
|
|
||||||
: toProjectId,
|
|
||||||
providerProjectId: showProjects ? giver?.handleId : fromProjectId,
|
|
||||||
recipientDid: receiver?.did,
|
|
||||||
recipientName: receiver?.name,
|
|
||||||
unitCode,
|
|
||||||
},
|
|
||||||
}"
|
}"
|
||||||
class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-lg mb-4"
|
class="block w-full text-center text-md uppercase bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-2 rounded-lg mb-4"
|
||||||
>
|
>
|
||||||
@@ -824,24 +810,46 @@ export default class GiftedDialog extends Vue {
|
|||||||
unitCode: string = "HUR",
|
unitCode: string = "HUR",
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
// Determine the correct parameters based on entity types
|
||||||
|
let fromDid: string | undefined;
|
||||||
|
let toDid: string | undefined;
|
||||||
|
let fulfillsProjectHandleId: string | undefined;
|
||||||
|
let providerPlanHandleId: string | undefined;
|
||||||
|
|
||||||
|
if (this.giverEntityType === "project" && this.recipientEntityType === "person") {
|
||||||
|
// Project-to-person gift
|
||||||
|
fromDid = undefined; // No person giver
|
||||||
|
toDid = recipientDid as string; // Person recipient
|
||||||
|
fulfillsProjectHandleId = undefined; // No project recipient
|
||||||
|
providerPlanHandleId = this.giver?.handleId; // Project giver
|
||||||
|
} else if (this.giverEntityType === "person" && this.recipientEntityType === "project") {
|
||||||
|
// Person-to-project gift
|
||||||
|
fromDid = giverDid as string; // Person giver
|
||||||
|
toDid = undefined; // No person recipient
|
||||||
|
fulfillsProjectHandleId = this.toProjectId; // Project recipient
|
||||||
|
providerPlanHandleId = undefined; // No project giver
|
||||||
|
} else {
|
||||||
|
// Person-to-person gift
|
||||||
|
fromDid = giverDid as string;
|
||||||
|
toDid = recipientDid as string;
|
||||||
|
fulfillsProjectHandleId = undefined;
|
||||||
|
providerPlanHandleId = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const result = await createAndSubmitGive(
|
const result = await createAndSubmitGive(
|
||||||
this.axios,
|
this.axios,
|
||||||
this.apiServer,
|
this.apiServer,
|
||||||
this.activeDid,
|
this.activeDid,
|
||||||
this.showProjects ? undefined : (giverDid as string),
|
fromDid,
|
||||||
this.showProjects && this.isFromProjectView
|
toDid,
|
||||||
? this.giver?.handleId
|
|
||||||
: (recipientDid as string),
|
|
||||||
description,
|
description,
|
||||||
amount,
|
amount,
|
||||||
unitCode,
|
unitCode,
|
||||||
this.showProjects && this.isFromProjectView
|
fulfillsProjectHandleId,
|
||||||
? this.giver?.handleId
|
|
||||||
: this.toProjectId,
|
|
||||||
this.offerId,
|
this.offerId,
|
||||||
false,
|
false,
|
||||||
undefined,
|
undefined,
|
||||||
this.showProjects ? this.giver?.handleId : undefined,
|
providerPlanHandleId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
@@ -1003,6 +1011,26 @@ export default class GiftedDialog extends Vue {
|
|||||||
};
|
};
|
||||||
this.currentStep = 2;
|
this.currentStep = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Computed property for the query parameters
|
||||||
|
get giftedDetailsQuery() {
|
||||||
|
return {
|
||||||
|
amountInput: this.amountInput,
|
||||||
|
description: this.description,
|
||||||
|
giverDid: this.giverEntityType === "person" ? this.giver?.did : undefined,
|
||||||
|
giverName: this.giver?.name,
|
||||||
|
offerId: this.offerId,
|
||||||
|
fulfillsProjectId: this.giverEntityType === "person" && this.recipientEntityType === "project"
|
||||||
|
? this.toProjectId
|
||||||
|
: undefined,
|
||||||
|
providerProjectId: this.giverEntityType === "project" && this.recipientEntityType === "person"
|
||||||
|
? this.giver?.handleId
|
||||||
|
: this.fromProjectId,
|
||||||
|
recipientDid: this.receiver?.did,
|
||||||
|
recipientName: this.receiver?.name,
|
||||||
|
unitCode: this.unitCode,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user