Hello! I have a message in logs like:
"Error: Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information."
and:
"jsonPayload":{
"message":"["message: ''\ndetails:\n applicationError:\n description: Forbidden\n code: FORBIDDEN\n data: {}"]"
even if I am logged in as admin before updating Event from Wix Events.
here is page code:
import { getLoginToken } from 'backend/login';
import { authentication } from 'wix-members';
import { getEventId } from 'backend/events.jsw'
import wixLocation from 'wix-location';
import { myUpdateWixEventFunction } from 'backend/events.jsw';
let path = wixLocation.path;
async function replaceRegLink(MyString,eventId){
const about=MyString.replace(/"_blank"/g,"'_self'");
console.log(about);
const eventInfo = {
about:about
};
const InfoOptions={};
await myUpdateWixEventFunction(eventId, eventInfo,InfoOptions)
.then(wixEvent => {
console.log("event updated");
})
.catch((error) => {
// event not updated
const updateError = error;
console.log(updateError);
});
}
$w.onReady(async function () {
$w('#login').onClick(async () => {
const email = $w('#email').value;
const password = $w('#password').value
// Call the backend function to get the session token
const loginResult = await getLoginToken(email, password);
if (loginResult.approved) {
// If approved, log the member in using the returned session token
authentication.applySessionToken(loginResult.sessionToken);
makeSelfLink();
console.log("Login succsess")
} else {
// If not approved, log a message
console.error('Login not approved.');
}
});
// await
async function makeSelfLink() {const myVariable = await getEventId(path);
const testLink = /("_blank")/.test(myVariable[0].about)
if(testLink)
{replaceRegLink(myVariable[0].about,myVariable[0]._id);}
else {console.log("no string");}
}
});
and backend events.jsw:
import { wixEvents } from "wix-events-backend";
export function myUpdateWixEventFunction(eventId,eventInfo,InfoOptions) {
return wixEvents.updateEvent(eventId,eventInfo,InfoOptions);
}
export async function getEventId(path){
return wixEvents.queryEvents()
.eq("slug",path[1])
.find()
.then((results) => {
const items = results.items;
console.log(results.items);
return items;
})
.catch((error) => {
const updateError1 = error;
});
}
and login.jsw:
import { authentication } from 'wix-members-backend';
export async function getLoginToken(email, password) {
let sessionToken;
try {
sessionToken = await authentication.login(email, password);
// If the promise resolves, the member is authenticated and can be logged in
return {
sessionToken: sessionToken,
approved: true
};
} catch (error) {
// If the promise is rejected, the member is not authenticated
// and cannot be logged in
console.error(error);
return {
approved: false,
error: error
};
}
}
I think few months ago, like october 2022, it was working as it is, but now it is not working…