CREATEORREPLACEFUNCTIONpublic.create_user(emailtext,passwordtext,uuiduuidDEFAULTNULL)RETURNSvoidAS$$declareuser_iduuid;encrypted_pwtext;BEGINuser_id:=COALESCE(uuid,gen_random_uuid());encrypted_pw:=crypt(password,gen_salt('bf'));INSERTINTOauth.users(instance_id,id,aud,role,email,encrypted_password,email_confirmed_at,recovery_sent_at,last_sign_in_at,raw_app_meta_data,raw_user_meta_data,created_at,updated_at,confirmation_token,email_change,email_change_token_new,recovery_token)VALUES('00000000-0000-0000-0000-000000000000',user_id,'authenticated','authenticated',email,encrypted_pw,'2023-05-03 19:41:43.585805+00','2023-04-22 13:10:03.275387+00','2023-04-22 13:10:31.458239+00','{"provider":"email","providers":["email"]}','{}','2023-05-03 19:41:43.580424+00','2023-05-03 19:41:43.585948+00','','','','');INSERTINTOauth.identities(id,user_id,identity_data,provider,provider_id,last_sign_in_at,created_at,updated_at)VALUES(gen_random_uuid(),user_id,format('{"sub":"%s","email":"%s"}',user_id::text,email)::jsonb,'email','eefcbf79-28b0-4070-acf4-54f3a941f932','2023-05-03 19:41:43.582456+00','2023-05-03 19:41:43.582497+00','2023-05-03 19:41:43.582497+00');END;$$LANGUAGEplpgsql;-- If no uuid is given, function would create a random oneselectpublic.create_user('YOUR@EMAIL.com','YOUR_PASSWORD','THIS UUID IS OPTIONAL');-- If you do not wanna use this function again, drop it:dropfunctionifexistspublic.create_usercascade;
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)