Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/shared/src/components/auth/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ function LoginForm({
</AlertParagraph>
</Alert>
)}
{hint && hint === labels.auth.error.socialAccountOnly && (
<Alert className="mt-6" type={AlertType.Error} flexDirection="flex-row">
<AlertParagraph className="!mt-0 flex-1">
It looks like you signed up with a different method. Try signing in
with your social provider instead.
</AlertParagraph>
</Alert>
)}
</AuthForm>
);
}
Expand Down
9 changes: 7 additions & 2 deletions packages/shared/src/hooks/useLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,20 @@ const useLogin = ({
},
onSuccess: async (res) => {
if (res.error) {
const isSocialOnly = res.code === 'SOCIAL_ACCOUNT_ONLY';
const displayedError = isSocialOnly
? labels.auth.error.socialAccountOnly
: labels.auth.error.invalidEmailOrPassword;
logEvent({
event_name: AuthEventNames.LoginError,
extra: JSON.stringify({
error: res.error,
displayedError: labels.auth.error.invalidEmailOrPassword,
code: res.code,
displayedError,
origin: 'betterauth email login',
}),
});
setHint(labels.auth.error.invalidEmailOrPassword);
setHint(displayedError);
return;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/lib/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const labels = {
'❌ We got some unexpected error from our side, nothing to worry about. Please try again.',
existingEmail:
'Email linked to different sign-in method. Please try another provider.',
socialAccountOnly:
'It looks like you signed up with a different method. Try signing in with your social provider instead.',
},
},
referral: {
Expand Down
Loading