-
+
Sign up
@@ -51,6 +51,8 @@ import { deleteUserData } from '@/utils/auth';
import { LOGGED_PERSON } from '@/graphql/actor';
import { IActor, IPerson } from '@/types/actor.model';
import { RouteName } from '@/router';
+import { CONFIG } from '@/graphql/config';
+import { IConfig } from '@/types/config.model';
@Component({
apollo: {
@@ -71,7 +73,10 @@ import { RouteName } from '@/router';
loggedPerson: {
query: LOGGED_PERSON,
},
- },
+ config: {
+ query: CONFIG,
+ }
+ }
})
export default class NavBar extends Vue {
notifications = [
@@ -83,6 +88,7 @@ export default class NavBar extends Vue {
searchText: string | null = null;
searchSelect = null;
loggedPerson!: IPerson;
+ config!: IConfig;
get items() {
return this.search.map(searchEntry => {
diff --git a/js/src/graphql/config.ts b/js/src/graphql/config.ts
index 07a16aba..46a73409 100644
--- a/js/src/graphql/config.ts
+++ b/js/src/graphql/config.ts
@@ -1,40 +1,10 @@
import gql from 'graphql-tag';
-export const CREATE_USER = gql`
-mutation CreateUser($email: String!, $password: String!) {
- createUser(email: $email, password: $password) {
- email,
- confirmationSentAt
- }
-}
-`;
-
-export const VALIDATE_USER = gql`
-mutation ValidateUser($token: String!) {
- validateUser(token: $token) {
- token,
- user {
- id,
- email,
- defaultActor {
- id
- }
- }
- }
-}
-`;
-
-export const CURRENT_USER_CLIENT = gql`
+export const CONFIG = gql`
query {
- currentUser @client {
- id,
- email
+ config {
+ name,
+ registrationsOpen
}
}
`;
-
-export const UPDATE_CURRENT_USER_CLIENT = gql`
-mutation UpdateCurrentUser($id: Int!, $email: String!) {
- updateCurrentUser(id: $id, email: $email) @client
-}
-`;
diff --git a/js/src/types/config.model.ts b/js/src/types/config.model.ts
index d3d3335e..78ff7d28 100644
--- a/js/src/types/config.model.ts
+++ b/js/src/types/config.model.ts
@@ -1,7 +1,5 @@
-import { ICurrentUser } from '@/types/current-user.model';
+export interface IConfig {
+ name: string,
-export interface ILogin {
- user: ICurrentUser,
-
- token: string,
+ registrationsOpen: boolean,
}
diff --git a/js/src/views/User/Login.vue b/js/src/views/User/Login.vue
index 770649bd..196ade97 100644
--- a/js/src/views/User/Login.vue
+++ b/js/src/views/User/Login.vue
@@ -37,7 +37,7 @@
Forgot your password ?
-
+
get_in([:registrations_open])
+ @moduledoc """
+ Instance configuration wrapper
+ """
- def instance_name(), do: instance_config() |> get_in([:name])
+ def registrations_open?() do
+ instance_config()
+ |> get_in([:registrations_open])
+ |> to_bool
+ end
+
+ def instance_name() do
+ instance_config()
+ |> get_in([:name])
+ end
defp instance_config(), do: Application.get_env(:mobilizon, :instance)
+
+ defp to_bool(v), do: v == true or v == "true" or v == "True"
end
diff --git a/lib/mobilizon_web/resolvers/config.ex b/lib/mobilizon_web/resolvers/config.ex
index 931403c9..f9b7b556 100644
--- a/lib/mobilizon_web/resolvers/config.ex
+++ b/lib/mobilizon_web/resolvers/config.ex
@@ -2,7 +2,7 @@ defmodule MobilizonWeb.Resolvers.Config do
@moduledoc """
Handles the config-related GraphQL calls
"""
- require Logger
+
import Mobilizon.CommonConfig
@doc """
diff --git a/test/mobilizon_web/resolvers/config_resolver_test.exs b/test/mobilizon_web/resolvers/config_resolver_test.exs
index bdbbc0b9..d9cb1bc9 100644
--- a/test/mobilizon_web/resolvers/config_resolver_test.exs
+++ b/test/mobilizon_web/resolvers/config_resolver_test.exs
@@ -18,7 +18,7 @@ defmodule MobilizonWeb.Resolvers.ConfigResolverTest do
context.conn
|> get("/api", AbsintheHelpers.query_skeleton(query, "config"))
- assert json_response(res, 200)["data"]["config"]["name"] == "Localhost"
+ assert json_response(res, 200)["data"]["config"]["name"] == "Test instance"
assert json_response(res, 200)["data"]["config"]["registrationsOpen"] == true
end
end