ApproveByToken Permission Error

I can’t manually approve waiting members I get an error with “FORBIDDEN” code here is the error:

Here is the page code:

import { approveMember } from 'backend/Members/member-helpers.jsw';
import wixLocation from 'wix-location';

$w.onReady(async function () {
    const token = wixLocation.query.token;
    const resourceId = wixLocation.query.resourceId;

    if (!token) {
        $w('#tite').text = 'E-Posta Doğrulanamadı!';
    } else {
        console.log('Token', token);
        const result = await approveMember(token, resourceId);

        if (result.approved === true) {
            $w('#tite').text = 'E-Posta Doğrulandı!';
            $w('#desc').expand();
        } else {
            $w('#tite').text = 'E-Posta Doğrulanamadı!';
        }
    }
});

Here is the backend code:

export async function approveMember(token, resourceId) {
    const verifyEmailChannel = { name: 'verify-email', resourceId };

    try {
        const sessionToken = await authentication.approveByToken(token);
        console.log('Session Token', sessionToken)
        const approvedData = {
            approved: true,
            sessionToken
        }

        await publish(verifyEmailChannel, approvedData);
        return approvedData;
    } catch (err) {
        const approvedData = { approved: false, reason: err }
        await publish(verifyEmailChannel, approvedData);
        console.error('Approve Error: ', err);
        return approvedData;
    }
}

So what happens is, I send an email to member and I added a button inside this email with a dynamic URL inside this URL I have approve token.

www.domain.com/verify?token=

But I can’t approve member manually by using approveByToken API I get an error that I shared above. I have tried few basic changes but no effects at all. Why I can’t approve member using this API??

-I use the token returned by register API. (and yes it’s string)

1 Like

Have you tested by manually triggering the function with the token as returned from register? Just to rule out that something is happening to the toke as it’s passed around.

Also, I assume you have your members set up for manual approval?

This could be a bug but I’m not sure yet

I see something else…

I think this code

const approvedData={
approved:true,
sessionToken
}

should be this

const approvedData={
approved:true,
sessionToken: sessionToken
}

No problem with sign up settings it’s on manual mode. I have tested it in the editor too.

It didn’t work. As I know I can just pass the variable in this version of JS Wix supports it. I tried but it didn’t work…

Btw I also tested the approveByEmail it’s also not working.

Yes I thought so too, was just double checking the docs and curious. I’ll see if I can find someone in product to take a look too. I’m not seeing anything else on the surface

Hi Enes,

I have the same problem, neither of the two functions works (approveByEmail and approveByToken).
Tested with async and sequential functions from backend but the result is always applicationError: code: “FORBIDDEN”
it seems to be a Wix bug, on my site it worked fine until a week ago when it stopped working with no code modifications.
I hope it can be resolved soon.

Hello, I have reported this but if you could please also open a ticket with customer care it will help the investigation as this is the official route to report bugs. Thank you!

Hi Amanda,

Thanks for your answer, I opened a ticket this past Thursday, December 8th, but I have not yet received a response from customer care.

I’m sorry to hear that. If I hear more I will also update here so you know what to expect. Keep us posted if you do get a resolution.

Ok, thanks if I get a response I’ll update you both too.

Testing same function time to time same results until now.

Hello,

Customer care just responded right now, told me that it should be fixed, I tested both functions (deprecated and new one) but it’s still throwing the same error.
I guess they’re working on that

Kind Regards

If they are reporting it is fixed and you are still seeing the error, I would respond and say that it is not fixed yet.

Same for me this should never take that much long to fix that. I don’t mean it’s easy to fix or etc I mean this is an API and an imporant API must be available always… But we can’t use it for days. Imagine you have problem in your sign up system for days…

Thanks Amanda,

I replied to the email sent by Dara (support @ wix.com) as soon as I checked that it was still not working

I’m also stuck with that problem, created a ticket.

Thank you for reporting through customer support. It’s the best way for them to be able to show the extent of the problem and how many it’s affecting.

Anyone else passing through these comments with the same issue, please reach out to CS so they can route appropriately. Thank you for your patience.

Yes, I know this is very frustrating and blocking for you and others. I do not have an update, but will report if I do before CS gets back to you. Have you had any response from them yet?