auth.users triggers throwing error.

Hey I have created a trigger on auth.users but it is throwing an error.

AuthException(message: Database error granting user, statusCode: 500)

CREATE OR REPLACE FUNCTION update_user_to_public()
RETURNS TRIGGER AS $$
BEGIN
UPDATE member
SET email = NEW.email, phone = NEW.phone
WHERE user_id = NEW.id;
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

CREATE TRIGGER user_updated_trigger
AFTER UPDATE ON auth.users
FOR EACH ROW
EXECUTE function update_user_to_public();

The trigger only throws error when doing an update, if I comment out the update part and just have a simple trigger with return new; it works fine.
Was this page helpful?