diff --git a/frontend/public/json-example/communities.json b/frontend/public/json-example/communities.json
deleted file mode 100644
index 26fb4a8e6..000000000
--- a/frontend/public/json-example/communities.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "community": [
- {"id": 1, "name": "Gradido Entwicklung", "url": "http://localhost:3000/vue/", "description":"Die lokale Entwicklungsumgebung von Gradido.", "registerUrl": "http://localhost:3000/vue/register"},
- {"id": 2, "name": "Gradido Staging", "url": "https://stage1.gradido.net/vue/", "description":"Der Testserver der Gradido Akademie.", "registerUrl": "https://stage1.gradido.net/vue/register"},
- {"id": 3, "name": "Gradido-Akademie", "url": "https://gdd1.gradido.com/vue/", "description":"Freies Institut für Wirtschaftsbionik.", "registerUrl": "https://gdd1.gradido.com/vue/register"}
- ]
-}
\ No newline at end of file
diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js
index 76d499de9..3499a3fa1 100644
--- a/frontend/src/graphql/queries.js
+++ b/frontend/src/graphql/queries.js
@@ -106,13 +106,13 @@ export const checkEmailQuery = gql`
}
`
-export const serverInformation = gql`
+export const communityInfo = gql`
query {
- serverInformation {
- community {
- name
- description
- }
+ getCommunityInfo {
+ name
+ description
+ registerUrl
+ url
}
}
`
diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js
index b581cd18a..f9b40fd15 100644
--- a/frontend/src/store/store.js
+++ b/frontend/src/store/store.js
@@ -43,7 +43,6 @@ export const actions = {
commit('lastName', data.lastName)
commit('description', data.description)
commit('newsletterState', data.klickTipp.newsletterState)
- commit('community', data.community)
},
logout: ({ commit, state }) => {
commit('token', null)
@@ -53,7 +52,6 @@ export const actions = {
commit('lastName', '')
commit('description', '')
commit('newsletterState', null)
- commit('community', null)
localStorage.clear()
},
}
diff --git a/frontend/src/views/Pages/Login.spec.js b/frontend/src/views/Pages/Login.spec.js
index 2d0daede0..6d4e807e9 100644
--- a/frontend/src/views/Pages/Login.spec.js
+++ b/frontend/src/views/Pages/Login.spec.js
@@ -4,14 +4,20 @@ import Login from './Login'
const localVue = global.localVue
-const loginQueryMock = jest.fn().mockResolvedValue({
+const apolloQueryMock = jest.fn().mockResolvedValue({
data: {
- login: 'token',
+ getCommunityInfo: {
+ name: 'test12',
+ description: 'test community 12',
+ url: 'http://test12.test12/',
+ registerUrl: 'http://test12.test12/vue/register',
+ },
},
})
const toastErrorMock = jest.fn()
const mockStoreDispach = jest.fn()
+const mockStoreCommit = jest.fn()
const mockRouterPush = jest.fn()
const spinnerHideMock = jest.fn()
const spinnerMock = jest.fn(() => {
@@ -30,6 +36,7 @@ describe('Login', () => {
$t: jest.fn((t) => t),
$store: {
dispatch: mockStoreDispach,
+ commit: mockStoreCommit,
state: {
community: {
name: 'Gradido Entwicklung',
@@ -49,7 +56,7 @@ describe('Login', () => {
error: toastErrorMock,
},
$apollo: {
- query: loginQueryMock,
+ query: apolloQueryMock,
},
}
@@ -70,6 +77,15 @@ describe('Login', () => {
expect(wrapper.find('div.login-form').exists()).toBeTruthy()
})
+ it('calls the communityInfo', () => {
+ expect(mockStoreCommit).toBeCalledWith('community', {
+ name: 'test12',
+ description: 'test community 12',
+ url: 'http://test12.test12/',
+ registerUrl: 'http://test12.test12/vue/register',
+ })
+ })
+
describe('Login header', () => {
it('has a welcome message', () => {
expect(wrapper.find('div.header').text()).toBe('Gradido site.login.community')
@@ -157,10 +173,15 @@ describe('Login', () => {
await flushPromises()
await wrapper.find('form').trigger('submit')
await flushPromises()
+ apolloQueryMock.mockResolvedValue({
+ data: {
+ login: 'token',
+ },
+ })
})
it('calls the API with the given data', () => {
- expect(loginQueryMock).toBeCalledWith(
+ expect(apolloQueryMock).toBeCalledWith(
expect.objectContaining({
variables: {
email: 'user@example.org',
@@ -190,7 +211,7 @@ describe('Login', () => {
describe('login fails', () => {
beforeEach(() => {
- loginQueryMock.mockRejectedValue({
+ apolloQueryMock.mockRejectedValue({
message: 'Ouch!',
})
})
diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue
index 81ed69067..bbbf9f0b6 100755
--- a/frontend/src/views/Pages/Login.vue
+++ b/frontend/src/views/Pages/Login.vue
@@ -67,7 +67,7 @@
import CONFIG from '../../config'
import InputPassword from '../../components/Inputs/InputPassword'
import InputEmail from '../../components/Inputs/InputEmail'
-import { login } from '../../graphql/queries'
+import { login, communityInfo } from '../../graphql/queries'
export default {
name: 'login',
@@ -112,6 +112,21 @@ export default {
this.$toasted.error(this.$t('error.no-account'))
})
},
+ async onCreated() {
+ this.$apollo
+ .query({
+ query: communityInfo,
+ })
+ .then((result) => {
+ this.$store.commit('community', result.data.getCommunityInfo)
+ })
+ .catch((error) => {
+ this.$toasted.error(error)
+ })
+ },
+ },
+ created() {
+ this.onCreated()
},
}
diff --git a/frontend/src/views/Pages/RegisterSelectCommunity.vue b/frontend/src/views/Pages/RegisterSelectCommunity.vue
index 31f8b4d7d..79620b458 100644
--- a/frontend/src/views/Pages/RegisterSelectCommunity.vue
+++ b/frontend/src/views/Pages/RegisterSelectCommunity.vue
@@ -37,7 +37,7 @@
-
+
{{ $t('community.switch-to-this-community') }}
@@ -51,7 +51,7 @@