chore(auth): refactor registration enabled setting in /info

This commit is contained in:
kolaente 2025-01-28 10:35:01 +01:00 committed by konrad
parent 9dc351f5a4
commit 90bf5ba81b
4 changed files with 17 additions and 13 deletions

View File

@ -15,7 +15,6 @@ export interface ConfigState {
motd: string,
linkSharingEnabled: boolean,
maxFileSize: string,
registrationEnabled: boolean,
availableMigrators: Array<keyof typeof MIGRATORS>,
taskAttachmentsEnabled: boolean,
totpEnabled: boolean,
@ -31,6 +30,7 @@ export interface ConfigState {
auth: {
local: {
enabled: boolean,
registrationEnabled: boolean,
},
ldap: {
enabled: boolean,
@ -52,7 +52,6 @@ export const useConfigStore = defineStore('config', () => {
motd: '',
linkSharingEnabled: true,
maxFileSize: '20MB',
registrationEnabled: true,
availableMigrators: [],
taskAttachmentsEnabled: true,
totpEnabled: true,
@ -68,6 +67,7 @@ export const useConfigStore = defineStore('config', () => {
auth: {
local: {
enabled: true,
registrationEnabled: true,
},
ldap: {
enabled: false,

View File

@ -169,7 +169,7 @@ const authStore = useAuthStore()
const configStore = useConfigStore()
const {redirectIfSaved} = useRedirectToLastVisited()
const registrationEnabled = computed(() => configStore.registrationEnabled)
const registrationEnabled = computed(() => configStore.auth.local.registrationEnabled)
const localAuthEnabled = computed(() => configStore.auth.local.enabled)
const ldapAuthEnabled = computed(() => configStore.auth.ldap.enabled)

View File

@ -1,5 +1,5 @@
<template>
<div v-if="configStore.registrationEnabled">
<div v-if="configStore.auth.local.registrationEnabled">
<Message
v-if="errorMessage !== ''"
variant="danger"

View File

@ -38,7 +38,6 @@ type vikunjaInfos struct {
Motd string `json:"motd"`
LinkSharingEnabled bool `json:"link_sharing_enabled"`
MaxFileSize string `json:"max_file_size"`
RegistrationEnabled bool `json:"registration_enabled"`
AvailableMigrators []string `json:"available_migrators"`
TaskAttachmentsEnabled bool `json:"task_attachments_enabled"`
EnabledBackgroundProviders []string `json:"enabled_background_providers"`
@ -55,12 +54,17 @@ type vikunjaInfos struct {
}
type authInfo struct {
Local enabledAuthInfo `json:"local"`
Ldap enabledAuthInfo `json:"ldap"`
OpenIDConnect openIDAuthInfo `json:"openid_connect"`
Local localAuthInfo `json:"local"`
Ldap ldapAuthInfo `json:"ldap"`
OpenIDConnect openIDAuthInfo `json:"openid_connect"`
}
type enabledAuthInfo struct {
type localAuthInfo struct {
Enabled bool `json:"enabled"`
RegistrationEnabled bool `json:"registration_enabled"`
}
type ldapAuthInfo struct {
Enabled bool `json:"enabled"`
}
@ -88,7 +92,6 @@ func Info(c echo.Context) error {
Motd: config.ServiceMotd.GetString(),
LinkSharingEnabled: config.ServiceEnableLinkSharing.GetBool(),
MaxFileSize: config.FilesMaxSize.GetString(),
RegistrationEnabled: config.AuthLocalEnabled.GetBool() && config.ServiceEnableRegistration.GetBool(),
TaskAttachmentsEnabled: config.ServiceEnableTaskAttachments.GetBool(),
TotpEnabled: config.ServiceEnableTotp.GetBool(),
CaldavEnabled: config.ServiceEnableCaldav.GetBool(),
@ -107,10 +110,11 @@ func Info(c echo.Context) error {
PrivacyPolicyURL: config.LegalPrivacyURL.GetString(),
},
AuthInfo: authInfo{
Local: enabledAuthInfo{
Enabled: config.AuthLocalEnabled.GetBool(),
Local: localAuthInfo{
Enabled: config.AuthLocalEnabled.GetBool(),
RegistrationEnabled: config.AuthLocalEnabled.GetBool() && config.ServiceEnableRegistration.GetBool(),
},
Ldap: enabledAuthInfo{
Ldap: ldapAuthInfo{
Enabled: config.AuthLdapEnabled.GetBool(),
},
OpenIDConnect: openIDAuthInfo{