Skip to content

Commit

Permalink
Merge pull request #919 from intuitem/CA-467-add-flag-to-hide-logo-on…
Browse files Browse the repository at this point in the history
…-login-page-for-enterprise-version

Ca 467 add flag to hide logo on login page for enterprise version
  • Loading branch information
nas-tabchiche authored Oct 14, 2024
2 parents de131f8 + aded679 commit d8e6ad4
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
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 };
};
2 changes: 2 additions & 0 deletions frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@
"noMailerConfigured": "No mailer configured",
"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",
"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",
"librariesCanOnlyBeLoadedByAdmin": "Libraries can only be loaded by an administrator",
"catalog": "Catalog",
"actions": "Actions",
Expand Down

0 comments on commit d8e6ad4

Please sign in to comment.