Skip to content

burggraf/supabase-roll-your-own-auth

Repository files navigation

supabase-roll-your-own-auth

Custom Supabase authentication using PostgreSQL functions

This is a set of PostgreSQL functions that perform customizable Supabase auth functions.

function: generate_auth_link(payload json)

This is the core function that generates a necessary link for the following purposes:

  • invite (used in a user invite email)
  • magiclink (used for password-less sign in emails)
  • recovery (used for password recovery emails)
  • signup (used for confirming email address for email signups)

generate an invite link

Send a JSON object to the function private.generate_auth_link function as follows:

select private.generate_auth_link(
'{
  "type": "invite",
  "email": "[email protected]",
  "data": { "foo": "bar2" },
  "redirect_to": "http://localhost:3000"
}'
);

Notes

generate a magiclink (password-less login)

Send a JSON object to the function private.generate_auth_link function as follows:

select private.generate_auth_link(
'{
  "type": "magiclink",
  "email": "[email protected]",
  "redirect_to": "http://localhost:3000"
}'
);

Notes

generate a recovery link (password recovery)

Send a JSON object to the function private.generate_auth_link function as follows:

select private.generate_auth_link(
'{
  "type": "recovery",
  "email": "[email protected]",
  "redirect_to": "http://localhost:3000"
}'
);

Notes

  • the redirect_to parameter can be customized for your application, including a complete path

generate a signup link (email registration)

Send a JSON object to the function private.generate_auth_link function as follows:

select private.generate_auth_link(
'{
  "type": "signup",
  "email": "[email protected]",
  "password": "password123",
  "data": { "foo": "bar2" },
  "redirect_to": "http://localhost:3000"
}'
);

Notes

  • the redirect_to parameter can be customized for your application, including a complete path

About

Custom Supabase authentication using PostgreSQL functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published