From f757cd2b76e4baaeac7011074b8995dfd4e2d089 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Tue, 3 Aug 2021 10:47:21 +0200 Subject: [PATCH] Withdrew state and errors from the UpdateUserInfosResponse object. --- backend/src/graphql/inputs/LoginUserInput.ts | 12 ++++----- .../graphql/models/UpdateUserInfosResponse.ts | 8 ------ backend/src/graphql/resolvers/UserResolver.ts | 27 +++++++++---------- .../helpers/MapVariableToColumnName.ts | 3 --- 4 files changed, 19 insertions(+), 31 deletions(-) delete mode 100644 backend/src/graphql/resolvers/helpers/MapVariableToColumnName.ts diff --git a/backend/src/graphql/inputs/LoginUserInput.ts b/backend/src/graphql/inputs/LoginUserInput.ts index 1f786702f..66f35980f 100644 --- a/backend/src/graphql/inputs/LoginUserInput.ts +++ b/backend/src/graphql/inputs/LoginUserInput.ts @@ -83,22 +83,22 @@ export class UpdateUserInfosArgs { email!: string @Field({ nullable: true }) - firstName?: string + firstName?: string | null @Field({ nullable: true }) - lastName?: string + lastName?: string | null @Field({ nullable: true }) - username?: string + username?: string | null @Field({ nullable: true }) - language?: string + language?: string | null @Field({ nullable: true }) - password?: string + password?: string | null @Field({ nullable: true }) - passwordNew?: string + passwordNew?: string | null } @ArgsType() diff --git a/backend/src/graphql/models/UpdateUserInfosResponse.ts b/backend/src/graphql/models/UpdateUserInfosResponse.ts index 820ee0011..765da5208 100644 --- a/backend/src/graphql/models/UpdateUserInfosResponse.ts +++ b/backend/src/graphql/models/UpdateUserInfosResponse.ts @@ -8,17 +8,9 @@ import { ObjectType, Field } from 'type-graphql' export class UpdateUserInfosResponse extends BaseEntity { constructor(json: any) { super() - this.state = json.state this.validValues = json.valid_values - this.errors = json.errors } - @Field(() => String) - state: string - @Field(() => Number) validValues: number - - @Field(() => [String]) - errors: [string] } diff --git a/backend/src/graphql/resolvers/UserResolver.ts b/backend/src/graphql/resolvers/UserResolver.ts index 5dc93f7bd..43d83938c 100644 --- a/backend/src/graphql/resolvers/UserResolver.ts +++ b/backend/src/graphql/resolvers/UserResolver.ts @@ -1,5 +1,5 @@ // import jwt from 'jsonwebtoken' -import { Resolver, Query, /* Mutation, */ Args, Arg, Field } from 'type-graphql' +import { Resolver, Query, Args, Arg } from 'type-graphql' import CONFIG from '../../config' import { ResetPasswordResponse } from '../models/ResetPasswordResponse' import { CheckUsernameResponse } from '../models/CheckUsernameResponse' @@ -142,24 +142,24 @@ export class UserResolver { { sessionId, email, - firstName = '', - lastName = '', - username = '', - language = '', - password = '', - passwordNew = '', + firstName = null, + lastName = null, + username = null, + language = null, + password = null, + passwordNew = null, }: UpdateUserInfosArgs, ): Promise { const payload = { session_id: sessionId, email, update: { - 'User.first_name': firstName.length > 0 ? firstName : undefined, - 'User.last_name': lastName.length > 0 ? lastName : undefined, - 'User.username': username.length > 0 ? username : undefined, - 'User.language': language.length > 0 ? language : undefined, - 'User.password': passwordNew.length > 0 ? passwordNew : undefined, - 'User.password_old': password.length > 0 ? password : undefined, + 'User.first_name': firstName !== null ? firstName : undefined, + 'User.last_name': lastName !== null ? lastName : undefined, + 'User.username': username !== null ? username : undefined, + 'User.language': language !== null ? language : undefined, + 'User.password': passwordNew !== null ? passwordNew : undefined, + 'User.password_old': password !== null ? password : undefined, }, } const result = await apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) @@ -167,7 +167,6 @@ export class UserResolver { return new UpdateUserInfosResponse(result.data) } - // TODO @Query(() => CheckUsernameResponse) async checkUsername( @Args() { username, groupId = 1 }: CheckUsernameArgs, diff --git a/backend/src/graphql/resolvers/helpers/MapVariableToColumnName.ts b/backend/src/graphql/resolvers/helpers/MapVariableToColumnName.ts deleted file mode 100644 index 361b35d9d..000000000 --- a/backend/src/graphql/resolvers/helpers/MapVariableToColumnName.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const MapVariableToColumnName = (object) => { - return null -}