Merge pull request #13004 from Budibase/fix/custom-branding-issue

Fix for custom branding not appearing on login
This commit is contained in:
Peter Clement 2024-02-14 10:32:06 +00:00 committed by GitHub
commit c86e1675b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 3 deletions

@ -1 +1 @@
Subproject commit 8cbe73c9dc39d0bda3dbca3dac345a4a1f916f18 Subproject commit 1ba8414bed14439512153cf851086146a80560f5

View File

@ -1,6 +1,7 @@
<script> <script>
import { auth, admin } from "stores/portal" import { auth, admin } from "stores/portal"
import { redirect } from "@roxi/routify" import { redirect } from "@roxi/routify"
import { CookieUtils } from "@budibase/frontend-core"
// If already authenticated, redirect away from the auth section. // If already authenticated, redirect away from the auth section.
// Check this onMount rather than a reactive statement to avoid trumping // Check this onMount rather than a reactive statement to avoid trumping
@ -9,6 +10,15 @@
$redirect("../") $redirect("../")
} }
if ($admin?.checklist?.branding) {
let url = new URL(window.location.href)
let hostname = url.hostname
let parts = hostname.split(".")
let tenantId = parts[0]
let domain = parts.slice(-2).join(".")
CookieUtils.setCookie("tenantId", tenantId, domain)
}
if ( if (
!$auth.user && !$auth.user &&
$admin.cloud && $admin.cloud &&

View File

@ -1,8 +1,12 @@
export function setCookie(name, value) { export function setCookie(name, value, domain) {
if (getCookie(name)) { if (getCookie(name)) {
removeCookie(name) removeCookie(name)
} }
window.document.cookie = `${name}=${value}; Path=/;` let cookieString = `${name}=${value}; Path=/;`
if (domain) {
cookieString += ` Domain=${domain};`
}
window.document.cookie = cookieString
} }
export function getCookie(cookieName) { export function getCookie(cookieName) {

View File

@ -498,6 +498,12 @@ export async function configChecklist(ctx: Ctx) {
// They have set up a global user // They have set up a global user
const userExists = await checkAnyUserExists() const userExists = await checkAnyUserExists()
// They have set up branding
const configDoc = await configs.getSettingsConfigDoc()
const config = configDoc.config
const branding = await pro.branding.getBrandingConfig(config)
return { return {
apps: { apps: {
checked: apps.length > 0, checked: apps.length > 0,
@ -519,6 +525,7 @@ export async function configChecklist(ctx: Ctx) {
label: "Set up single sign-on", label: "Set up single sign-on",
link: "/builder/portal/settings/auth", link: "/builder/portal/settings/auth",
}, },
branding,
} }
} }
) )