diff --git a/src/backend/InvenTree/InvenTree/settings.py b/src/backend/InvenTree/InvenTree/settings.py
index ec4e2458f5..a1053b16aa 100644
--- a/src/backend/InvenTree/InvenTree/settings.py
+++ b/src/backend/InvenTree/InvenTree/settings.py
@@ -1314,6 +1314,7 @@ HEADLESS_FRONTEND_URLS = {
'account_reset_password': 'http://localhost:8000/password-reset',
'account_reset_password_from_key': 'http://localhost:8000/password-reset-key/{key}', # noqa: RUF027
'account_signup': 'http://localhost:8000/signup',
+ 'socialaccount_login_error': 'http://localhost:8000/social-login-error',
}
HEADLESS_ONLY = True
HEADLESS_TOKEN_STRATEGY = 'InvenTree.auth_overrides.DRFTokenStrategy'
diff --git a/src/frontend/src/components/buttons/SSOButton.tsx b/src/frontend/src/components/buttons/SSOButton.tsx
index fc136768f7..ba7e8cb44b 100644
--- a/src/frontend/src/components/buttons/SSOButton.tsx
+++ b/src/frontend/src/components/buttons/SSOButton.tsx
@@ -15,10 +15,7 @@ import {
} from '@tabler/icons-react';
import { t } from '@lingui/macro';
-import { showNotification } from '@mantine/notifications';
-import { api } from '../../App';
-import { ApiEndpoints } from '../../enums/ApiEndpoints';
-import { apiUrl } from '../../states/ApiState';
+import { ProviderLogin } from '../../functions/auth';
import type { Provider } from '../../states/states';
const brandIcons: { [key: string]: JSX.Element } = {
@@ -36,43 +33,17 @@ const brandIcons: { [key: string]: JSX.Element } = {
};
export function SsoButton({ provider }: Readonly<{ provider: Provider }>) {
- function login() {
- // set preferred provider
- api
- .put(
- apiUrl(ApiEndpoints.ui_preference),
- { preferred_method: 'pui' },
- { headers: { Authorization: '' } }
- )
- .then(() => {
- // redirect to login
- window.location.href = provider.login;
- })
- .catch(() => {
- showNotification({
- title: t`Error`,
- message: t`Sign in redirect failed.`,
- color: 'red'
- });
- });
- }
-
return (
);
diff --git a/src/frontend/src/components/forms/AuthenticationForm.tsx b/src/frontend/src/components/forms/AuthenticationForm.tsx
index 71b99f6573..0335b76943 100644
--- a/src/frontend/src/components/forms/AuthenticationForm.tsx
+++ b/src/frontend/src/components/forms/AuthenticationForm.tsx
@@ -34,7 +34,12 @@ export function AuthenticationForm() {
});
const simpleForm = useForm({ initialValues: { email: '' } });
const [classicLoginMode, setMode] = useDisclosure(true);
- const [auth_settings] = useServerApiState((state) => [state.auth_settings]);
+ const [auth_settings, sso_enabled, password_forgotten_enabled] =
+ useServerApiState((state) => [
+ state.auth_settings,
+ state.sso_enabled,
+ state.password_forgotten_enabled
+ ]);
const navigate = useNavigate();
const location = useLocation();
const { isLoggedIn } = useUserState();
@@ -98,10 +103,10 @@ export function AuthenticationForm() {
return (
<>
- {auth_settings?.sso_enabled === true ? (
+ {sso_enabled() ? (
<>
- {auth_settings.providers.map((provider) => (
+ {auth_settings?.socialaccount.providers.map((provider) => (
))}
@@ -130,7 +135,7 @@ export function AuthenticationForm() {
placeholder={t`Your password`}
{...classicForm.getInputProps('password')}
/>
- {auth_settings?.password_forgotten_enabled === true && (
+ {password_forgotten_enabled() === true && (
[state.auth_settings]);
+ const [auth_settings, registration_enabled, sso_registration] =
+ useServerApiState((state) => [
+ state.auth_settings,
+ state.registration_enabled,
+ state.sso_registration_enabled
+ ]);
const [isRegistering, setIsRegistering] = useState(false);
function handleRegistration() {
@@ -232,11 +242,10 @@ export function RegistrationForm() {
});
}
- const both_reg_enabled =
- auth_settings?.registration_enabled && auth_settings?.sso_registration;
+ const both_reg_enabled = registration_enabled() && sso_registration();
return (
<>
- {auth_settings?.registration_enabled && (
+ {registration_enabled() && (