mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
remove check against referrer and in case of invalid signing use simply
decoded payload
This commit is contained in:
parent
fc991b76a4
commit
0e41e6518c
@ -143,10 +143,7 @@ export class TransactionLinkResolver {
|
||||
|
||||
@Authorized([RIGHTS.QUERY_TRANSACTION_LINK])
|
||||
@Query(() => QueryLinkResult)
|
||||
async queryTransactionLink(
|
||||
@Arg('code') code: string,
|
||||
@Arg('referrer') referrer: string,
|
||||
): Promise<typeof QueryLinkResult> {
|
||||
async queryTransactionLink(@Arg('code') code: string): Promise<typeof QueryLinkResult> {
|
||||
logger.debug('TransactionLinkResolver.queryTransactionLink... code=', code)
|
||||
const transactionLink = new TransactionLink()
|
||||
if (code.match(/^CL-/)) {
|
||||
@ -210,18 +207,24 @@ export class TransactionLinkResolver {
|
||||
disburseJwtPayload.sendercommunityuuid,
|
||||
)
|
||||
}
|
||||
const senderUrl = senderCom.url.replace(/\/api\/?$/, '')
|
||||
if (!senderUrl.startsWith(referrer)) {
|
||||
throw new LogError('Sender community does not match referrer', senderCom.name, referrer)
|
||||
}
|
||||
if (!senderCom.communityUuid) {
|
||||
throw new LogError('Sender community UUID is not set')
|
||||
}
|
||||
// now with the sender community UUID the jwt token can be verified
|
||||
const jwtPayload = await verify(code, senderCom.communityUuid)
|
||||
let jwtPayload = await verify(code, senderCom.communityUuid)
|
||||
// TODO: as long as the verification fails, fallback to decode
|
||||
if (jwtPayload === null) {
|
||||
jwtPayload = decode(code)
|
||||
}
|
||||
logger.debug('TransactionLinkResolver.queryTransactionLink... jwtPayload=', jwtPayload)
|
||||
if (jwtPayload !== null && jwtPayload instanceof DisbursementJwtPayloadType) {
|
||||
const disburseJwtPayload: DisbursementJwtPayloadType = jwtPayload
|
||||
const disburseJwtPayload = new DisbursementJwtPayloadType(jwtPayload.sendercommunityuuid,
|
||||
jwtPayload.sendergradidoid,
|
||||
jwtPayload.sendername,
|
||||
jwtPayload.redeemcode,
|
||||
jwtPayload.amount,
|
||||
jwtPayload.memo,
|
||||
)
|
||||
logger.debug(
|
||||
'TransactionLinkResolver.queryTransactionLink... disburseJwtPayload=',
|
||||
disburseJwtPayload,
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
<div
|
||||
:link-data="linkData"
|
||||
:redeem-code="redeemCode"
|
||||
:referrer="referrer"
|
||||
:is-contribution-link="isContributionLink"
|
||||
class="redeem-community-selection"
|
||||
>
|
||||
@ -49,7 +48,6 @@ import { useMutation } from '@vue/apollo-composable'
|
||||
const props = defineProps({
|
||||
linkData: { type: Object, required: true },
|
||||
redeemCode: { type: String, required: true },
|
||||
referrer: { type: String, required: true },
|
||||
isContributionLink: { type: Boolean, default: false },
|
||||
receiverCommunity: {
|
||||
type: Object,
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
v-model:receiver-community="receiverCommunity"
|
||||
:link-data="props.linkData"
|
||||
:redeem-code="props.redeemCode"
|
||||
:referrer="props.referrer"
|
||||
:is-contribution-link="props.isContributionLink"
|
||||
/>
|
||||
|
||||
@ -40,7 +39,6 @@ const { login, register } = useAuthLinks()
|
||||
const props = defineProps({
|
||||
linkData: { type: Object, required: true },
|
||||
redeemCode: { type: String, required: true },
|
||||
referrer: { type: String, required: true },
|
||||
isContributionLink: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
|
||||
@ -128,8 +128,8 @@ export const checkUsername = gql`
|
||||
`
|
||||
|
||||
export const queryTransactionLink = gql`
|
||||
query ($code: String!, $referrer: String!) {
|
||||
queryTransactionLink(code: $code, referrer: $referrer) {
|
||||
query ($code: String!) {
|
||||
queryTransactionLink(code: $code) {
|
||||
... on TransactionLink {
|
||||
id
|
||||
amount
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
<redeem-select-community
|
||||
:link-data="linkData"
|
||||
:redeem-code="redeemCode"
|
||||
:referrer="referrer"
|
||||
:is-contribution-link="isContributionLink"
|
||||
/>
|
||||
</template>
|
||||
@ -72,23 +71,17 @@ const linkData = ref({
|
||||
|
||||
const redeemedBoxText = ref('')
|
||||
|
||||
const { result, onResult, loading, error, onError } = useQuery(queryTransactionLink, {
|
||||
const { result, onResult, error, onError } = useQuery(queryTransactionLink, {
|
||||
code: params.code,
|
||||
referrer: meta.referrer,
|
||||
})
|
||||
|
||||
const {
|
||||
mutate: redeemMutate,
|
||||
loading: redeemLoading,
|
||||
error: redeemError,
|
||||
} = useMutation(redeemTransactionLink)
|
||||
const { mutate: redeemMutate } = useMutation(redeemTransactionLink)
|
||||
|
||||
const isContributionLink = computed(() => {
|
||||
return params.code?.search(/^CL-/) === 0
|
||||
})
|
||||
|
||||
const redeemCode = computed(() => params.code)
|
||||
const referrer = computed(() => meta.referrer)
|
||||
|
||||
const tokenExpiresInSeconds = computed(() => {
|
||||
const remainingSecs = Math.floor(
|
||||
@ -102,7 +95,6 @@ const validLink = computed(() => {
|
||||
})
|
||||
|
||||
const itemType = computed(() => {
|
||||
console.log('TransactionLink.itemType... referrer=', referrer.value, meta.referrer)
|
||||
if (linkData.value.deletedAt) {
|
||||
console.log('TransactionLink.itemType... TEXT_DELETED')
|
||||
return 'TEXT_DELETED'
|
||||
@ -174,26 +166,22 @@ const emit = defineEmits(['set-mobile-start'])
|
||||
|
||||
onMounted(() => {
|
||||
console.log('TransactionLink.onMounted... params=', params)
|
||||
console.log('TransactionLink.onMounted... meta=', meta)
|
||||
emit('set-mobile-start', false)
|
||||
})
|
||||
|
||||
onResult(() => {
|
||||
console.log('TransactionLink.onResult... result=', result)
|
||||
console.log('TransactionLink.onResult... referrer=', referrer.value, meta.referrer)
|
||||
if (!result || !result.value) return
|
||||
setTransactionLinkInformation()
|
||||
})
|
||||
|
||||
onError(() => {
|
||||
console.log('TransactionLink.onError... error=', error)
|
||||
console.log('TransactionLink.onError... referrer=', referrer.value, meta.referrer)
|
||||
toastError(t('gdd_per_link.redeemlink-error'))
|
||||
})
|
||||
|
||||
function setTransactionLinkInformation() {
|
||||
console.log('TransactionLink.setTransactionLinkInformation... result=', result)
|
||||
console.log('TransactionLink.setTransactionLinkInformation... referrer=', referrer.value, meta.referrer)
|
||||
const { queryTransactionLink } = result.value
|
||||
console.log(
|
||||
'TransactionLink.setTransactionLinkInformation... queryTransactionLink=',
|
||||
|
||||
@ -1,13 +1,5 @@
|
||||
import NotFound from '@/pages/NotFoundPage'
|
||||
|
||||
function setReferrerToMeta(to, from) {
|
||||
console.log('setReferrerToMeta... to=', to)
|
||||
console.log('setReferrerToMeta... from=', from)
|
||||
if (Object.keys(from.query).length) {
|
||||
to.meta.referrer = from.path
|
||||
}
|
||||
}
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/authenticate',
|
||||
@ -164,13 +156,6 @@ const routes = [
|
||||
{
|
||||
path: '/redeem/:code',
|
||||
component: () => import('@/pages/TransactionLink'),
|
||||
beforeEnter: (to, from) => {
|
||||
setReferrerToMeta(to, from)
|
||||
return true
|
||||
},
|
||||
meta: {
|
||||
referrer: 'unknown',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/:catchAll(.*)',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user