diff --git a/config/config.exs b/config/config.exs index b28988f38..fef8c6ddd 100644 --- a/config/config.exs +++ b/config/config.exs @@ -19,6 +19,7 @@ config :mobilizon, :instance, registrations_open: false, registration_email_allowlist: [], registration_email_denylist: [], + disable_database_login: false, languages: [], default_language: "en", demo: false, diff --git a/js/src/components/NavBar.vue b/js/src/components/NavBar.vue index fe6dfccd6..0db9c3b64 100644 --- a/js/src/components/NavBar.vue +++ b/js/src/components/NavBar.vue @@ -185,11 +185,7 @@ >{{ t("Login") }} -
  • +
  • { + return ( + (registrationsOpen.value || registrationsAllowlist.value) && + databaseLogin.value + ); +}); // const mobileNavbarActive = ref(false); diff --git a/js/src/composition/apollo/config.ts b/js/src/composition/apollo/config.ts index b040535dd..06c28a29a 100644 --- a/js/src/composition/apollo/config.ts +++ b/js/src/composition/apollo/config.ts @@ -208,7 +208,10 @@ export function useSearchConfig() { export function useRegistrationConfig() { const { result, error, loading, onResult } = useQuery<{ - config: Pick; + config: Pick< + IConfig, + "registrationsOpen" | "registrationsAllowlist" | "auth" + >; }>(REGISTRATIONS, undefined, { fetchPolicy: "cache-only" }); const registrationsOpen = computed( @@ -217,9 +220,11 @@ export function useRegistrationConfig() { const registrationsAllowlist = computed( () => result.value?.config.registrationsAllowlist ); + const databaseLogin = computed(() => result.value?.config.auth.databaseLogin); return { registrationsOpen, registrationsAllowlist, + databaseLogin, error, loading, onResult, diff --git a/js/src/graphql/config.ts b/js/src/graphql/config.ts index 65dc681bf..b55fb06de 100644 --- a/js/src/graphql/config.ts +++ b/js/src/graphql/config.ts @@ -79,6 +79,7 @@ export const CONFIG = gql` } auth { ldap + databaseLogin oauthProviders { id label @@ -386,6 +387,7 @@ export const LOGIN_CONFIG = gql` query LoginConfig { config { auth { + databaseLogin oauthProviders { id label @@ -450,6 +452,9 @@ export const REGISTRATIONS = gql` config { registrationsOpen registrationsAllowlist + auth { + databaseLogin + } } } `; diff --git a/js/src/types/config.model.ts b/js/src/types/config.model.ts index e2ed75994..60ae7fc1b 100644 --- a/js/src/types/config.model.ts +++ b/js/src/types/config.model.ts @@ -106,6 +106,7 @@ export interface IConfig { version: string; auth: { ldap: boolean; + databaseLogin: boolean; oauthProviders: IOAuthProvider[]; }; uploadLimits: { diff --git a/js/src/views/User/LoginView.vue b/js/src/views/User/LoginView.vue index ad7964ef0..78a89be39 100644 --- a/js/src/views/User/LoginView.vue +++ b/js/src/views/User/LoginView.vue @@ -42,7 +42,7 @@ > {{ error }} -
    + -
    - -
    -
    {{ t("Didn't receive the instructions?") }} -

    +

    +
    + +
    @@ -162,7 +163,10 @@ const route = useRoute(); const { currentUser } = useCurrentUserClient(); const { result: configResult } = useQuery<{ - config: Pick; + config: Pick< + IConfig, + "auth" | "registrationsOpen" | "registrationsAllowlist" + >; }>(LOGIN_CONFIG); const config = computed(() => configResult.value?.config); diff --git a/lib/graphql/resolvers/config.ex b/lib/graphql/resolvers/config.ex index e35b26fed..9fe01d8f9 100644 --- a/lib/graphql/resolvers/config.ex +++ b/lib/graphql/resolvers/config.ex @@ -156,6 +156,8 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do federating: Config.instance_federating(), auth: %{ ldap: Config.ldap_enabled?(), + database_login: + Application.get_env(:mobilizon, :instance) |> get_in([:disable_database_login]) == false, oauth_providers: Config.oauth_consumer_strategies() }, upload_limits: %{ diff --git a/lib/graphql/schema/config.ex b/lib/graphql/schema/config.ex index 27561783c..ca8880d07 100644 --- a/lib/graphql/schema/config.ex +++ b/lib/graphql/schema/config.ex @@ -305,6 +305,7 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do """ object :auth do field(:ldap, :boolean, description: "Whether or not LDAP auth is enabled") + field(:database_login, :boolean, description: "Whether or not database login is enabled") field(:oauth_providers, list_of(:oauth_provider), description: "List of oauth providers") end