Withdrew state and errors from the UpdateUserInfosResponse object.

This commit is contained in:
Hannes Heine 2021-08-03 10:47:21 +02:00
parent 99a37ddb0a
commit f757cd2b76
4 changed files with 19 additions and 31 deletions

View File

@ -83,22 +83,22 @@ export class UpdateUserInfosArgs {
email!: string email!: string
@Field({ nullable: true }) @Field({ nullable: true })
firstName?: string firstName?: string | null
@Field({ nullable: true }) @Field({ nullable: true })
lastName?: string lastName?: string | null
@Field({ nullable: true }) @Field({ nullable: true })
username?: string username?: string | null
@Field({ nullable: true }) @Field({ nullable: true })
language?: string language?: string | null
@Field({ nullable: true }) @Field({ nullable: true })
password?: string password?: string | null
@Field({ nullable: true }) @Field({ nullable: true })
passwordNew?: string passwordNew?: string | null
} }
@ArgsType() @ArgsType()

View File

@ -8,17 +8,9 @@ import { ObjectType, Field } from 'type-graphql'
export class UpdateUserInfosResponse extends BaseEntity { export class UpdateUserInfosResponse extends BaseEntity {
constructor(json: any) { constructor(json: any) {
super() super()
this.state = json.state
this.validValues = json.valid_values this.validValues = json.valid_values
this.errors = json.errors
} }
@Field(() => String)
state: string
@Field(() => Number) @Field(() => Number)
validValues: number validValues: number
@Field(() => [String])
errors: [string]
} }

View File

@ -1,5 +1,5 @@
// import jwt from 'jsonwebtoken' // 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 CONFIG from '../../config'
import { ResetPasswordResponse } from '../models/ResetPasswordResponse' import { ResetPasswordResponse } from '../models/ResetPasswordResponse'
import { CheckUsernameResponse } from '../models/CheckUsernameResponse' import { CheckUsernameResponse } from '../models/CheckUsernameResponse'
@ -142,24 +142,24 @@ export class UserResolver {
{ {
sessionId, sessionId,
email, email,
firstName = '', firstName = null,
lastName = '', lastName = null,
username = '', username = null,
language = '', language = null,
password = '', password = null,
passwordNew = '', passwordNew = null,
}: UpdateUserInfosArgs, }: UpdateUserInfosArgs,
): Promise<UpdateUserInfosResponse> { ): Promise<UpdateUserInfosResponse> {
const payload = { const payload = {
session_id: sessionId, session_id: sessionId,
email, email,
update: { update: {
'User.first_name': firstName.length > 0 ? firstName : undefined, 'User.first_name': firstName !== null ? firstName : undefined,
'User.last_name': lastName.length > 0 ? lastName : undefined, 'User.last_name': lastName !== null ? lastName : undefined,
'User.username': username.length > 0 ? username : undefined, 'User.username': username !== null ? username : undefined,
'User.language': language.length > 0 ? language : undefined, 'User.language': language !== null ? language : undefined,
'User.password': passwordNew.length > 0 ? passwordNew : undefined, 'User.password': passwordNew !== null ? passwordNew : undefined,
'User.password_old': password.length > 0 ? password : undefined, 'User.password_old': password !== null ? password : undefined,
}, },
} }
const result = await apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) const result = await apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
@ -167,7 +167,6 @@ export class UserResolver {
return new UpdateUserInfosResponse(result.data) return new UpdateUserInfosResponse(result.data)
} }
// TODO
@Query(() => CheckUsernameResponse) @Query(() => CheckUsernameResponse)
async checkUsername( async checkUsername(
@Args() { username, groupId = 1 }: CheckUsernameArgs, @Args() { username, groupId = 1 }: CheckUsernameArgs,

View File

@ -1,3 +0,0 @@
export const MapVariableToColumnName = (object) => {
return null
}