Supabase.GoTrue (supabase_gotrue v0.3.9)
This module provides the functionality to interact with the GoTrue API, allowing management of users, sessions, and authentication.
It also aims to provide integrations with Plug and Phoenix LiveView applications.
For detailed information about the GoTrue API, check the official documentation at https://supabase.io/docs/reference/javascript/auth-api
And also refer to functions and submodules documentation for more information.
Summary
Functions
Retrieves the auth module handle from the application configuration. Check https://hexdocs.pm/supabase_gotrue/readme.html#usage
Get the user associated with the current session.
Resends a signuo confirm email for the given email address.
Sends a recovery password email for the given email address.
Signs in a user with ID token.
Signs in a user with OAuth.
Signs in a user with OTP.
Signs in a user with email/phone and password.
Signs in a user with SSO.
Signs up a user with email/phone and password.
Updates the current logged in user.
Verifies an OTP code.
Functions
get_auth_module!()
Retrieves the auth module handle from the application configuration. Check https://hexdocs.pm/supabase_gotrue/readme.html#usage
get_user(client, session)
Get the user associated with the current session.
Parameters
client- TheSupabaseclient to use for the request.session- The session to use for the request. CheckSupabase.GoTrue.Sessionfor more information.
Examples
iex> session = %Supabase.GoTrue.Session{access_token: "example_token"}
iex> Supabase.GoTrue.get_user(pid | client_name, session)
{:ok, %Supabase.GoTrue.User{}}
resend(client, email, opts)
@spec resend(Supabase.Client.t(), String.t(), opts) :: :ok | {:error, term()} when opts: [{:redirect_to, String.t()}] | [{:captcha_token, String.t()}] | [redirect_to: String.t(), captcha_token: String.t()]
Resends a signuo confirm email for the given email address.
Parameters
client- TheSupabaseclient to use for the request.email- A valid user email address to recover passwordopts:redirect_to: the url where the user should be redirected to reset their passwordcaptcha_token
Examples
iex> Supabase.GoTrue.resend(client, "john@example.com", redirect_to: "http://localohst:4000/reset-pass") :ok
reset_password_for_email(client, email, opts)
@spec reset_password_for_email(Supabase.Client.t(), String.t(), opts) :: :ok | {:error, term()} when opts: [{:redirect_to, String.t()}] | [{:captcha_token, String.t()}] | [redirect_to: String.t(), captcha_token: String.t()]
Sends a recovery password email for the given email address.
Parameters
client- TheSupabaseclient to use for the request.email- A valid user email address to recover passwordopts:redirect_to: the url where the user should be redirected to reset their passwordcaptcha_token
Examples
iex> Supabase.GoTrue.reset_password_for_email(client, "john@example.com", redirect_to: "http://localohst:4000/reset-pass") :ok
sign_in_with_id_token(client, credentials)
Signs in a user with ID token.
Parameters
client- TheSupabaseclient to use for the request.credentials- The credentials to use for the sign in. CheckSupabase.GoTrue.Schemas.SignInWithIdTokenfor more information.
Examples
iex> credentials = %Supabase.GoTrue.SignInWithIdToken{}
iex> Supabase.GoTrue.sign_in_with_id_token(pid | client_name, credentials)
{:ok, %Supabase.GoTrue.User{}}
sign_in_with_oauth(client, credentials)
Signs in a user with OAuth.
Parameters
client- TheSupabaseclient to use for the request.credentials- The credentials to use for the sign in. CheckSupabase.GoTrue.Schemas.SignInWithOauthfor more information.
Examples
iex> credentials = %Supabase.GoTrue.SignInWithOauth{}
iex> Supabase.GoTrue.sign_in_with_oauth(pid | client_name, credentials)
{:ok, atom, URI.t()}
sign_in_with_otp(client, credentials)
Signs in a user with OTP.
Parameters
client- TheSupabaseclient to use for the request.credentials- The credentials to use for the sign in. CheckSupabase.GoTrue.Schemas.SignInWithOTPfor more information.
Examples
iex> credentials = %Supabase.GoTrue.SignInWithOTP{}
iex> Supabase.GoTrue.sign_in_with_otp(pid | client_name, credentials)
{:ok, %Supabase.GoTrue.Session{}}
sign_in_with_password(client, credentials)
Signs in a user with email/phone and password.
Parameters
client- TheSupabaseclient to use for the request.credentials- The credentials to use for the sign in. CheckSupabase.GoTrue.Schemas.SignInWithPasswordfor more information.
Examples
iex> credentials = %Supabase.GoTrue.SignInWithPassword{}
iex> Supabase.GoTrue.sign_in_with_password(pid | client_name, credentials)
{:ok, %Supabase.GoTrue.Session{}}
sign_in_with_sso(client, credentials)
Signs in a user with SSO.
Parameters
client- TheSupabaseclient to use for the request.credentials- The credentials to use for the sign in. CheckSupabase.GoTrue.Schemas.SignInWithSSOfor more information.
Examples
iex> credentials = %Supabase.GoTrue.SignInWithSSO{}
iex> Supabase.GoTrue.sign_in_with_sso(pid | client_name, credentials)
{:ok, %Supabase.GoTrue.User{}}
sign_up(client, credentials)
Signs up a user with email/phone and password.
Parameters
client- TheSupabaseclient to use for the request.credentials- The credentials to use for the sign up. CheckSupabase.GoTrue.Schemas.SignUpWithPasswordfor more information.
Examples
iex> credentials = %Supabase.GoTrue.SignUpWithPassword{}
iex> Supabase.GoTrue.sign_up(pid | client_name, credentials)
{:ok, %Supabase.GoTrue.User{}}
update_user(client, conn, attrs)
@spec update_user(Supabase.Client.t(), conn, Supabase.GoTrue.Schemas.UserParams.t()) :: {:ok, conn} | {:error, term()} when conn: Plug.Conn.t() | Phoenix.LiveView.Socket.t()
Updates the current logged in user.
Parameters
client- TheSupabaseclient to use for the request.conn- The currentPlug.ConnorPhoenix.LiveView.Socketto get current userattrs- CheckUserParams
Examples
iex> params = %{email: "another@example.com", password: "new-pass"} iex> Supabase.GoTrue.update_user(client, conn, params)
verify_otp(client, params)
Verifies an OTP code.
Parameters
client- TheSupabaseclient to use for the request.params- The parameters to use for the verification. CheckSupabase.GoTrue.Schemas.VerifyOTPfor more information.
Examples
iex> params = %Supabase.GoTrue.VerifyOTP{}
iex> Supabase.GoTrue.verify_otp(pid | client_name, params)
{:ok, %Supabase.GoTrue.Session{}}