I’m trying to hack around this, but I haven’t found a way to check whether the user is registered already, before registering him again, this way, users now can register themselves till infinity. I’d like to check if user exists already and either log them - with the credentials, or redirect them to login.
Is there a way to maybe check if user exists in Supabase?
if supabase lets you ‘reregister’ users till the universe ends, you could think about setting up a precondition, perhaps using a simple edgeFunction that checks if there is a user with that email
so the logic would be
user fills out registration form
weweb calls out to a supabse function
the supabase function checks for the existence of a user with that email
if they dont exist, sign them up
if they exist, do nothing
return a message to weweb that the function ran succesfully
show the user a message that instructs them to check their inbox for an email. this way users can’t ‘check to see’ if a user has already signed up for your site AND doesnt reregister them.
Yeah, this is a valid option, but I’m wondering whether either the Supabase Auth implementation or WeWeb hasn’t a quicker solution for this. But yeah, if there won’t be any other option, I’ll code my own logic for this.
DECLARE
user_id uuid;
BEGIN
SELECT id
INTO user_id
FROM users
WHERE users.email = validate_user_exists.email;
RETURN user_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN NULL;
END;