diff --git a/ui/dev-dist/sw.js b/ui/dev-dist/sw.js index 42002658..2426796c 100644 --- a/ui/dev-dist/sw.js +++ b/ui/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.gqab4md54bg" + "revision": "0.8f1s6la51s8" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/ui/src/views/auth/Login.tsx b/ui/src/views/auth/Login.tsx index 80610d85..5dbbf726 100644 --- a/ui/src/views/auth/Login.tsx +++ b/ui/src/views/auth/Login.tsx @@ -45,7 +45,6 @@ const validationSchema = Yup.object().shape({ const Login = () => { const navigate = useNavigate() const isMultiTenant = useStoreState((a) => a.abpConfig.config?.multiTenancy.isEnabled) - const tenantId = useStoreState((a) => a.auth.tenantId) const { setTenantId } = useStoreActions((a) => a.auth) const [message, setMessage] = useState('') @@ -66,6 +65,24 @@ const Login = () => { const { signIn } = useAuth() const { translate } = useLocalization() + const getSubdomain = () => { + if (typeof window === 'undefined') return null + + const hostname = window.location.hostname + + const parts = hostname.split('.') + + if (hostname === 'localhost' || parts.length < 3) { + return null + } + + if (parts[0] === 'www') { + return parts[1] + } + + return parts[0].toUpperCase() + } + const onSignIn = async ( values: SignInFormSchema, { setSubmitting, isSubmitting, setFieldValue, setFieldTouched }: any, @@ -161,6 +178,8 @@ const Login = () => { } } + const tenantId = useStoreState((a) => a.auth.tenantId) ?? getSubdomain() + useEffect(() => { if (!isMultiTenant) { return