Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ca 467 add flag to hide logo on login page for enterprise version #919

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 5.1.1 on 2024-10-10 11:59

import django.db.models.deletion
import iam.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('enterprise_core', '0001_initial'),
('iam', '0008_user_is_third_party'),
]

operations = [
migrations.AddField(
model_name='clientsettings',
name='show_images_unauthenticated',
field=models.BooleanField(default=True, help_text='Show logo and favicon to unauthenticated users'),
),
migrations.AlterField(
model_name='clientsettings',
name='folder',
field=models.ForeignKey(default=iam.models.Folder.get_root_folder_id, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_folder', to='iam.folder'),
),
]
15 changes: 10 additions & 5 deletions enterprise/backend/enterprise_core/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from enum import Enum
import base64
import os
from enum import Enum

import magic
from django.core.validators import FileExtensionValidator
from django.db import models
from iam.models import FolderMixin
from django.utils.translation import gettext_lazy as _

from core.base_models import AbstractBaseModel
from core.utils import sha256

import base64
import magic
from iam.models import FolderMixin


class ClientSettings(AbstractBaseModel, FolderMixin):
Expand All @@ -28,6 +30,9 @@ class FileField(Enum):
blank=True,
validators=[FileExtensionValidator(["ico", "png", "jpeg", "jpg", "webp"])],
)
show_images_unauthenticated = models.BooleanField(
default=True, help_text=_("Show logo and favicon to unauthenticated users")
)

@property
def logo_base64(self):
Expand Down
5 changes: 3 additions & 2 deletions enterprise/frontend/src/lib/utils/client-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { z } from 'zod';

export const ClientSettingsSchema = z.object({
id: z.string().uuid(),
name: z.string().optional().nullable(),
name: z.string().optional().nullable().default(''),
logo: z.any().optional().nullable(),
favicon: z.any().optional().nullable()
favicon: z.any().optional().nullable(),
show_images_unauthenticated: z.boolean().default(true),
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { ClientSettingsSchema } from '$lib/utils/client-settings';
import { zod } from 'sveltekit-superforms/adapters';
import FileInput from '$lib/components/Forms/FileInput.svelte';
import Checkbox from '$lib/components/Forms/Checkbox.svelte';
import * as m from '$paraglide/messages.js';

export let data: PageData;
Expand Down Expand Up @@ -41,6 +42,12 @@
: m.faviconHelpText()}
accept="image/*"
/>
<Checkbox
{form}
field="show_images_unauthenticated"
label={m.showImagesUnauthenticated()}
helpText={m.showImagesUnauthenticatedHelpText()}
/>
<button
class="btn variant-filled-primary font-semibold w-full"
data-testid="save-button"
Expand Down
6 changes: 6 additions & 0 deletions enterprise/frontend/src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ export const load: LayoutServerLoad = async ({ fetch, locals }) => {
const _settings = await fetch('/settings/client-settings').then((res) => res.json());
clientSettings = { name: 'clientSettings', settings: _settings };
} else clientSettings = locals.globalSettings;
if (!locals.user && clientSettings.settings.show_images_unauthenticated !== true) {
clientSettings.settings.logo = '';
clientSettings.settings.favicon = '';
clientSettings.settings.logo_hash = '';
clientSettings.settings.favicon_hash = '';
}
return { featureFlags: locals.featureFlags, clientSettings };
};
4 changes: 3 additions & 1 deletion frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -752,5 +752,7 @@
"ShowOnlyAssessable": "Only assessable",
"NoPreviewMessage": "No preview available.",
"errorLicenseSeatsExceeded": "The number of license seats is exceeded, you will not be able to grant editing rights to this user. Please contact your administrator.",
"availableSeats": "Available seats"
"availableSeats": "Available seats",
"showImagesUnauthenticated": "Show logo and favicon to unauthenticated users",
"showImagesUnauthenticatedHelpText": "If disabled, the regular CISO Assistant logo and favicon will be displayed on the login screen"
}
Loading