Skip to content

Commit

Permalink
frontend: Notify users if we fail to log in via SSO (#796)
Browse files Browse the repository at this point in the history
Notify users if we fail to log in via SSO
  • Loading branch information
malexw authored Oct 3, 2024
1 parent b2099b7 commit 56186ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useParams, useRouter, useSearchParams } from 'next/navigation';
import { useEffect } from 'react';

import { Text } from '@/components/UI';
import { useAuthConfig, useSession } from '@/hooks';
import { useAuthConfig, useNotify, useSession } from '@/hooks';
import { getQueryString } from '@/utils';

/**
Expand All @@ -19,6 +19,7 @@ const OauthCallback: React.FC = () => {
const redirect = getQueryString(search.get('redirect_uri'));
const code = getQueryString(search.get('code'));
const { loginStrategies: ssoLogins } = useAuthConfig();
const notify = useNotify();

const loginType = ssoLogins.find(
(login) => encodeURIComponent(login.strategy.toLowerCase()) == params.strategy
Expand All @@ -39,6 +40,7 @@ const OauthCallback: React.FC = () => {
router.push(redirect || '/');
},
onError: () => {
notify.error('Failed to validate Google OAuth credentials');
router.push('/login');
},
}
Expand All @@ -56,6 +58,7 @@ const OauthCallback: React.FC = () => {
router.push(redirect || '/');
},
onError: () => {
notify.error('Failed to validate OAuth credentials');
router.push('/login');
},
}
Expand Down
4 changes: 0 additions & 4 deletions src/interfaces/assistants_web/src/app/(auth)/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ const Login: React.FC = () => {
<Text
as="h1"
styleAs="h3"
onClick={() => {
console.warn('Clicked title');
errors.push('Clicked title');
}}
>
Log in
</Text>
Expand Down

0 comments on commit 56186ce

Please sign in to comment.