diff --git a/backend/src/middleware/permissionsMiddleware.js b/backend/src/middleware/permissionsMiddleware.js
index 736ce20a9..0f45304fd 100644
--- a/backend/src/middleware/permissionsMiddleware.js
+++ b/backend/src/middleware/permissionsMiddleware.js
@@ -57,6 +57,7 @@ const permissions = shield({
UpdateBadge: isAdmin,
DeleteBadge: isAdmin,
AddUserBadges: isAdmin,
+ addSocialMedia: isAuthenticated,
// AddBadgeRewarded: isAdmin,
// RemoveBadgeRewarded: isAdmin,
reward: isAdmin,
diff --git a/backend/src/resolvers/user_management.js b/backend/src/resolvers/user_management.js
index 26dfb81db..d77b67c82 100644
--- a/backend/src/resolvers/user_management.js
+++ b/backend/src/resolvers/user_management.js
@@ -100,6 +100,25 @@ export default {
return encode(currentUser)
}
+ },
+ addSocialMedia: async (_, { url }, { driver, user }) => {
+ const session = driver.session()
+
+ const { email } = user
+ const result = await session.run(
+ `MATCH (user:User {email: $userEmail})
+ SET user.socialMedia = [$url]
+ RETURN user {.socialMedia}`,
+ {
+ userEmail: email,
+ url
+ }
+ )
+ session.close()
+ const [currentUser] = result.records.map(record => {
+ return record.get('user')
+ })
+ return !!currentUser.socialMedia
}
}
}
diff --git a/backend/src/schema.graphql b/backend/src/schema.graphql
index 3b1d95a95..6d757cb41 100644
--- a/backend/src/schema.graphql
+++ b/backend/src/schema.graphql
@@ -26,6 +26,7 @@ type Mutation {
disable(id: ID!): ID
enable(id: ID!): ID
reward(fromBadgeId: ID!, toUserId: ID!): ID
+ addSocialMedia(url: String!): Boolean!
unreward(fromBadgeId: ID!, toUserId: ID!): ID
"Shout the given Type and ID"
shout(id: ID!, type: ShoutTypeEnum): Boolean! @cypher(statement: """
@@ -120,6 +121,7 @@ type User {
location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
locationName: String
about: String
+ socialMedia: [String]
createdAt: String
updatedAt: String
diff --git a/cypress/integration/SocialMedia.feature b/cypress/integration/SocialMedia.feature
new file mode 100644
index 000000000..05ecfc882
--- /dev/null
+++ b/cypress/integration/SocialMedia.feature
@@ -0,0 +1,14 @@
+Feature: List Social Media Accounts
+ As a User
+ I'd like to enter my social media
+ So I can show them to other users to get in contact
+
+ Background:
+ Given I have a user account
+ And I am logged in
+ And I am on the "settings" page
+
+ Scenario: Adding Social Media
+ Given I click on the "My social media" link
+ Then I should be on the "/settings/my-social-media" page
+ And I should be able to add a social media link
diff --git a/cypress/integration/common/settings.js b/cypress/integration/common/settings.js
index 3aa6022a8..c87d15aec 100644
--- a/cypress/integration/common/settings.js
+++ b/cypress/integration/common/settings.js
@@ -61,3 +61,30 @@ Then(
'I can see my new name {string} when I click on my profile picture in the top right',
name => matchNameInUserMenu(name)
)
+
+When('I click on the {string} link', link => {
+ cy.get('a')
+ .contains(link)
+ .click()
+})
+
+Then('I should be on the {string} page', page => {
+ cy.location()
+ .should(loc => {
+ expect(loc.pathname).to.eq(page)
+ })
+ .get('h3')
+ .should('contain', 'My social media')
+})
+
+Then('I should be able to add a social media link', () => {
+ cy.get("input[name='social-media']")
+ .type('https://freeradical.zone/@mattwr18')
+ .get('button')
+ .contains('Add social media')
+ .click()
+ .get('.iziToast-message')
+ .should('contain', 'Updated user')
+ .get('a')
+ .contains("src='https://freeradical.zone/@mattwr18'")
+})
diff --git a/webapp/locales/en.json b/webapp/locales/en.json
index fe92f901a..b3e2909ca 100644
--- a/webapp/locales/en.json
+++ b/webapp/locales/en.json
@@ -47,6 +47,11 @@
},
"languages": {
"name": "Languages"
+ },
+ "social-media": {
+ "name": "My social media",
+ "submit": "Add social media",
+ "success": "Updated user"
}
},
"admin": {
diff --git a/webapp/pages/settings.vue b/webapp/pages/settings.vue
index 9e2d63056..0352975d0 100644
--- a/webapp/pages/settings.vue
+++ b/webapp/pages/settings.vue
@@ -54,6 +54,10 @@ export default {
{
name: this.$t('settings.languages.name'),
path: `/settings/languages`
+ },
+ {
+ name: this.$t('settings.social-media.name'),
+ path: `/settings/my-social-media`
}
]
}
diff --git a/webapp/pages/settings/my-social-media.vue b/webapp/pages/settings/my-social-media.vue
new file mode 100644
index 000000000..07d981a76
--- /dev/null
+++ b/webapp/pages/settings/my-social-media.vue
@@ -0,0 +1,75 @@
+
+
+