Sveltekit auth helper update row (with RLS) fails without error
I have a +page.server.js default action with the following code:
Both the session & supabaseClient seem fine, but after the update profileData, and profileError are both undefined.
Am I missing something?
import { getSupabase } from '@supabase/auth-helpers-sveltekit';
import { error, redirect } from '@sveltejs/kit';
/** @type {import('./$types').Actions} */
export const actions = {
default: async (event) => {
const { request } = event;
const { session, supabaseClient } = await getSupabase(event);
console.log('supabaseClient', supabaseClient);
if (!session) {
// the user is not signed in
throw error(403, { message: 'Unauthorized' });
}
const formData = await request.formData();
const { data: profileData, error: profileError } = supabaseClient
.from('profile')
.update({
first_name: formData.get('first_name'),
family_name: formData.get('family_name'),
phone: formData.get('phone'),
mobile: formData.get('mobile'),
mobile_reception: parseInt(formData.get('mobile_reception')),
rfs_survival_plan: formData.get('rfs_survival_plan')
})
.eq('id', session.user.id);
console.log('profileData', profileData);
console.log('profileError', profileError);
if (profileError) {
console.log('update error profileAboutMe:', profileError);
throw error(400, profileError.message);
}
return {
user: session.user,
profileData
};
}
};import { getSupabase } from '@supabase/auth-helpers-sveltekit';
import { error, redirect } from '@sveltejs/kit';
/** @type {import('./$types').Actions} */
export const actions = {
default: async (event) => {
const { request } = event;
const { session, supabaseClient } = await getSupabase(event);
console.log('supabaseClient', supabaseClient);
if (!session) {
// the user is not signed in
throw error(403, { message: 'Unauthorized' });
}
const formData = await request.formData();
const { data: profileData, error: profileError } = supabaseClient
.from('profile')
.update({
first_name: formData.get('first_name'),
family_name: formData.get('family_name'),
phone: formData.get('phone'),
mobile: formData.get('mobile'),
mobile_reception: parseInt(formData.get('mobile_reception')),
rfs_survival_plan: formData.get('rfs_survival_plan')
})
.eq('id', session.user.id);
console.log('profileData', profileData);
console.log('profileError', profileError);
if (profileError) {
console.log('update error profileAboutMe:', profileError);
throw error(400, profileError.message);
}
return {
user: session.user,
profileData
};
}
};Both the session & supabaseClient seem fine, but after the update profileData, and profileError are both undefined.
Am I missing something?