From aecd53831a37388caa4fcd03f5e8352bd6b3cb83 Mon Sep 17 00:00:00 2001 From: Charis <26616127+charislam@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:45:21 -0500 Subject: [PATCH] remove deprecated orphan page (#20940) --- .../pages/guides/auth/auth-password-reset.mdx | 250 ------------------ 1 file changed, 250 deletions(-) delete mode 100644 apps/docs/pages/guides/auth/auth-password-reset.mdx diff --git a/apps/docs/pages/guides/auth/auth-password-reset.mdx b/apps/docs/pages/guides/auth/auth-password-reset.mdx deleted file mode 100644 index 7490f1edb1f..00000000000 --- a/apps/docs/pages/guides/auth/auth-password-reset.mdx +++ /dev/null @@ -1,250 +0,0 @@ -import Layout from '~/layouts/DefaultGuideLayout' -import { Accordion } from 'ui' - -export const meta = { - id: 'auth-password-reset', - title: 'Password Reset', - description: 'How to reset password with Supabase Auth', -} - -- Send email for password reset using [`.resetPasswordForEmail`](/docs/reference/javascript/auth-resetpasswordforemail) while providing a `redirectTo` parameter -- Email link will work as a magic link and log the user in then take them to the url specified in the `redirectTo` parameter -- Create form to update the password and call the [`.updateUser`](/docs/reference/javascript/auth-updateuser) method with the new password - -## Single Page Application (SPA) - -### Sending password reset email - - - - -Supabase provides a convenient method [`.resetPasswordForEmail`](/docs/reference/javascript/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectTo` which we will use to pass an absolute URL to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user. - -```js -await supabase.auth.resetPasswordForEmail('hello@example.com', { - redirectTo: 'http://example.com/account/update-password', -}) -``` - - - - -Supabase provides a convenient method [`.resetPasswordForEmail`](/docs/reference/kotlin/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectUrl` which we will use to pass an absolute URL to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user. - -```kotlin -supabase.auth.resetPasswordForEmail( - email = "hello@example.com", - redirectUrl = "http://example.com/account/update-password" -) -``` - -If you are on one of the Kotlin targets that have built-in support for redirect url handling like Android, you may want to checkout [OAuth and OTP link verification](https://supabase.com/docs/reference/kotlin/initializing). - - - - -### Email link - -The email link you receive will work like a magic link. This way when you click the link you will be logged into the website. Since we passed a redirect URL to the [`.resetPasswordForEmail`](https://supabase.com/docs/reference/javascript/auth-resetpasswordforemail) method the user should be sent to the update password page. - -### Update password - - - - -To update the password we call the [`.updateUser`](/docs/reference/javascript/auth-updateuser) method and pass along the new password to this method. - -```js -await supabase.auth.updateUser({ password: new_password }) -``` - - - - -To update the password we call the [`.modifyUser`](/docs/reference/kotlin/auth-updateuser) method and pass along the new password to this method. - -```kotlin -supabase.auth.modifyUser { - password = "new_password" -} -``` - - - - -## Server-Side Rendering (SSR) - -### Sending password reset email - - - - -Supabase provides a convenient method [`.resetPasswordForEmail`](/docs/reference/javascript/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectTo` which we will use to pass an absolute URL to the callback page along with a query parameter to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user. - -```js -await supabase.auth.resetPasswordForEmail('hello@example.com', { - redirectTo: 'http://example.com/api/auth/callback?next=/account/update-password', -}) -``` - - - -We are using `next` as our query parameter, but this can name whatever you like. - - - - - - -Supabase provides a convenient method [`.resetPasswordForEmail`](/docs/reference/kotlin/auth-resetpasswordforemail) to reset a user password. This method takes a parameter of `redirectUrl` which we will use to pass an absolute URL to the update password page. This URL must be saved in your allowed [Redirect URLs](https://supabase.com/dashboard/project/_/auth/url-configuration) list found at [Authentication > Redirect Configuration](https://supabase.com/dashboard/project/_/auth/url-configuration) or it won't redirect the user. - -```kotlin -supabase.auth.resetPasswordForEmail( - email = "hello@example.com", - redirectUrl = "http://example.com/api/auth/callback?next=/account/update-password" -) -``` - -If you are on one of the Kotlin targets that have built-in support for redirect url handling like Android, you may want to checkout [OAuth and OTP link verification](https://supabase.com/docs/reference/kotlin/initializing). - - - - -### Email link - -The email link you receive will behave like a magic link. When the link is clicked you will be sent to the `redirectTo` URL you specified that points to the path with the exchange code. - -### Exchange authorization code - - - - -After redirecting to the server page, we need to retrieve the code from the query parameter called `code` and pass it to the `.exchangeCodeForSession` function. - -```js -// api/auth/callback.ts - -// The code is retrieved from the query parameter - use whichever mechanism is recommended -// for your app/framework. This is just an example. -const code = url.searchParams.get('code') - -// call the Supabase API to exchange the code for a session -await supabase.auth.exchangeCodeForSession(code) -``` - - - -The query parameter is always `code` for the authorization code returned from the Supabase API - - - -We will also need to check for the `next` query parameter to redirect the user to the update password page. - -```ts -// api/auth/callback.ts - -// The password page path is retrieved from the query parameter - use whichever mechanism is recommended -// for your app/framework. This is just an example. -const next = url.searchParams.get('next') - -// using Next.js API response object in this example -res.redirect(next) -``` - - - - -Here is an example on Android: - -```kotlin -//Wherever you initialize your SupabaseClient: -val client = createSupabaseClient(supabaseUrl, supabaseKey) { - install(GoTrue) { - flowType = FlowType.PKCE - scheme = "exampleApp" - host = "callback" - } -} -``` - -```xml - - - - - - - - -``` - -```kotlin -//MainActivity.kt -override fun onCreate() { - client.handleDeeplinks(intent) -} -``` - -That's it! `supabase-kt` will take care of parsing and importing the session. Other targets are similar, you can check [OAuth and OTP link verification](https://supabase.com/docs/reference/kotlin/initializing) for more information. - - - - -### Update password - - - - -To update the password we call the [`.updateUser`](/docs/reference/javascript/auth-updateuser) method and pass along the new password to this method. - -```js -await supabase.auth.updateUser({ password: new_password }) -``` - - - - -To update the password we call the [`.modifyUser`](/docs/reference/kotlin/auth-updateuser) method and pass along the new password to this method. - -```kotlin -supabase.auth.modifyUser { - password = "new_password" -} -``` - - - - -export const Page = ({ children }) => - -export default Page