From 158265951271a181aa8ef125c558096d6633edb8 Mon Sep 17 00:00:00 2001 From: scosman Date: Sun, 11 Feb 2024 12:40:50 -0500 Subject: [PATCH] Fix https://github.com/CriticalMoments/CMSaasStarter/issues/13 We were telling users they had oauth just because they weren't logged in with a password. That's not necessarily true, they can log in via a link (verify email link, magic link). Make the oauth part of the message conditional on knowing for certain they logged in with oauth. Also clean up copy and style. --- .../settings/change_password/+page.svelte | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/routes/(admin)/account/(menu)/settings/change_password/+page.svelte b/src/routes/(admin)/account/(menu)/settings/change_password/+page.svelte index ba3dcdea..11c3741f 100644 --- a/src/routes/(admin)/account/(menu)/settings/change_password/+page.svelte +++ b/src/routes/(admin)/account/(menu)/settings/change_password/+page.svelte @@ -10,10 +10,16 @@ export let data let { session, supabase } = data + // True if definitely has a password, but can be false if they + // logged in with oAuth or email link let hasPassword = session?.user?.amr?.find((x) => x.method === "password") ? true : false + let usingOAuth = session?.user?.amr?.find((x) => x.method === "oauth") + ? true + : false + let sendBtn: HTMLButtonElement let sentEmail = false let sendForgotPassword = () => { @@ -36,7 +42,7 @@ Change Password -

Settings

+

Change Password

{#if hasPassword} {:else} -
- +
-
- You currently do not use a password to log in. -
-
- You use oAuth ("Sign in with Github" or similar). You can continue to - use your account using only oAuth if you like! -
+ {#if usingOAuth} +
Set Password By Email
+
+ You use oAuth to sign in ("Sign in with Github" or similar). You can + continue to access your account using only oAuth if you like! +
+ {:else} +
Change Password By Email
+ {/if}
- If you'd like to set a password to compliment your oAuth login, click - the button below. It will send you an email at {session?.user?.email} which - will allow you to set a password. + The button below will send you an email at {session?.user?.email} which will + allow you to set your password.