From 5ff9842c0bf7b2ca012ebdfb0b0b0cdd57165c0f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 30 Aug 2021 16:54:37 +0200 Subject: [PATCH] change user data without sessionId --- backend/src/graphql/inputs/LoginUserInput.ts | 3 --- backend/src/graphql/resolvers/UserResolver.ts | 5 +++-- frontend/src/components/LanguageSwitch.vue | 4 ++-- frontend/src/graphql/queries.js | 2 -- .../src/views/Pages/UserProfile/UserCard_FormUserData.vue | 2 -- .../src/views/Pages/UserProfile/UserCard_FormUserMail.vue | 1 - .../views/Pages/UserProfile/UserCard_FormUserPasswort.vue | 1 - .../src/views/Pages/UserProfile/UserCard_FormUsername.vue | 1 - 8 files changed, 5 insertions(+), 14 deletions(-) diff --git a/backend/src/graphql/inputs/LoginUserInput.ts b/backend/src/graphql/inputs/LoginUserInput.ts index 19326689e..f92cf5510 100644 --- a/backend/src/graphql/inputs/LoginUserInput.ts +++ b/backend/src/graphql/inputs/LoginUserInput.ts @@ -38,9 +38,6 @@ export class ChangePasswordArgs { @ArgsType() export class UpdateUserInfosArgs { - @Field(() => Number) - sessionId!: number - @Field(() => String) email!: string diff --git a/backend/src/graphql/resolvers/UserResolver.ts b/backend/src/graphql/resolvers/UserResolver.ts index 42a7be6da..dd8240e02 100644 --- a/backend/src/graphql/resolvers/UserResolver.ts +++ b/backend/src/graphql/resolvers/UserResolver.ts @@ -108,11 +108,11 @@ export class UserResolver { return 'sucess' } + @Authorized() @Query(() => UpdateUserInfosResponse) async updateUserInfos( @Args() { - sessionId, email, firstName, lastName, @@ -122,9 +122,10 @@ export class UserResolver { password, passwordNew, }: UpdateUserInfosArgs, + @Ctx() context: any, ): Promise { const payload = { - session_id: sessionId, + session_id: context.sessionId, email, update: { 'User.first_name': firstName || undefined, diff --git a/frontend/src/components/LanguageSwitch.vue b/frontend/src/components/LanguageSwitch.vue index e6f9c86c3..54c3728cc 100644 --- a/frontend/src/components/LanguageSwitch.vue +++ b/frontend/src/components/LanguageSwitch.vue @@ -32,13 +32,13 @@ export default { localeChanged(locale) }, async saveLocale(locale) { + if (this.$i18n.locale === locale) return this.setLocale(locale) - if (this.$store.state.sessionId && this.$store.state.email) { + if (this.$store.state.email) { this.$apollo .query({ query: updateUserInfos, variables: { - sessionId: this.$store.state.sessionId, email: this.$store.state.email, locale: locale, }, diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js index ca5572493..035a73ee2 100644 --- a/frontend/src/graphql/queries.js +++ b/frontend/src/graphql/queries.js @@ -29,7 +29,6 @@ export const loginViaEmailVerificationCode = gql` export const updateUserInfos = gql` query( - $sessionId: Float! $email: String! $firstName: String $lastName: String @@ -40,7 +39,6 @@ export const updateUserInfos = gql` $locale: String ) { updateUserInfos( - sessionId: $sessionId email: $email firstName: $firstName lastName: $lastName diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue index 369d30074..3726b5298 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserData.vue @@ -85,7 +85,6 @@ export default { data() { return { showUserData: true, - sessionId: this.$store.state.sessionId, form: { firstName: this.$store.state.firstName, lastName: this.$store.state.lastName, @@ -118,7 +117,6 @@ export default { .query({ query: updateUserInfos, variables: { - sessionId: this.$store.state.sessionId, email: this.$store.state.email, firstName: this.form.firstName, lastName: this.form.lastName, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue index b5c4f30bb..ed88425c7 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserMail.vue @@ -48,7 +48,6 @@ export default { .query({ query: updateUserInfos, variables: { - sessionId: this.$store.state.sessionId, email: this.$store.state.email, newEmail: this.newEmail, }, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue index a9be983c1..4678defaf 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUserPasswort.vue @@ -81,7 +81,6 @@ export default { .query({ query: updateUserInfos, variables: { - sessionId: this.$store.state.sessionId, email: this.$store.state.email, password: this.form.password, passwordNew: this.form.newPassword.password, diff --git a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue index 1c269ba53..f6587b968 100644 --- a/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue +++ b/frontend/src/views/Pages/UserProfile/UserCard_FormUsername.vue @@ -90,7 +90,6 @@ export default { .query({ query: updateUserInfos, variables: { - sessionId: this.$store.state.sessionId, email: this.$store.state.email, username: this.form.username, },