Subdomain

This commit is contained in:
Sedat ÖZTÜRK 2025-05-14 09:18:42 +03:00
parent 1e2466fd37
commit 08e3d01291
2 changed files with 21 additions and 2 deletions

View file

@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812" "revision": "3ca0b8505b4bec776b69afdba2768812"
}, { }, {
"url": "index.html", "url": "index.html",
"revision": "0.gqab4md54bg" "revision": "0.8f1s6la51s8"
}], {}); }], {});
workbox.cleanupOutdatedCaches(); workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

View file

@ -45,7 +45,6 @@ const validationSchema = Yup.object().shape({
const Login = () => { const Login = () => {
const navigate = useNavigate() const navigate = useNavigate()
const isMultiTenant = useStoreState((a) => a.abpConfig.config?.multiTenancy.isEnabled) const isMultiTenant = useStoreState((a) => a.abpConfig.config?.multiTenancy.isEnabled)
const tenantId = useStoreState((a) => a.auth.tenantId)
const { setTenantId } = useStoreActions((a) => a.auth) const { setTenantId } = useStoreActions((a) => a.auth)
const [message, setMessage] = useState('') const [message, setMessage] = useState('')
@ -66,6 +65,24 @@ const Login = () => {
const { signIn } = useAuth() const { signIn } = useAuth()
const { translate } = useLocalization() 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 ( const onSignIn = async (
values: SignInFormSchema, values: SignInFormSchema,
{ setSubmitting, isSubmitting, setFieldValue, setFieldTouched }: any, { setSubmitting, isSubmitting, setFieldValue, setFieldTouched }: any,
@ -161,6 +178,8 @@ const Login = () => {
} }
} }
const tenantId = useStoreState((a) => a.auth.tenantId) ?? getSubdomain()
useEffect(() => { useEffect(() => {
if (!isMultiTenant) { if (!isMultiTenant) {
return return