mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
reduced checkUsername response to a boolean
This commit is contained in:
parent
973fad7ea9
commit
9540ab3208
@ -1,13 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@ObjectType()
|
||||
export class CheckUsernameResponse {
|
||||
constructor(json: any) {
|
||||
this.state = json.state
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
state: string
|
||||
}
|
||||
@ -3,8 +3,8 @@
|
||||
|
||||
import { Resolver, Query, Args, Arg, Authorized, Ctx, UseMiddleware, Mutation } from 'type-graphql'
|
||||
import { from_hex as fromHex } from 'libsodium-wrappers'
|
||||
import { getCustomRepository } from 'typeorm'
|
||||
import CONFIG from '../../config'
|
||||
import { CheckUsernameResponse } from '../model/CheckUsernameResponse'
|
||||
import { LoginViaVerificationCode } from '../model/LoginViaVerificationCode'
|
||||
import { SendPasswordResetEmailResponse } from '../model/SendPasswordResetEmailResponse'
|
||||
import { UpdateUserInfosResponse } from '../model/UpdateUserInfosResponse'
|
||||
@ -22,7 +22,6 @@ import {
|
||||
klicktippNewsletterStateMiddleware,
|
||||
} from '../../middleware/klicktippMiddleware'
|
||||
import { CheckEmailResponse } from '../model/CheckEmailResponse'
|
||||
import { getCustomRepository } from 'typeorm'
|
||||
import { UserSettingRepository } from '../../typeorm/repository/UserSettingRepository'
|
||||
import { Setting } from '../enum/Setting'
|
||||
import { UserRepository } from '../../typeorm/repository/User'
|
||||
@ -276,8 +275,8 @@ export class UserResolver {
|
||||
return response
|
||||
}
|
||||
|
||||
@Query(() => CheckUsernameResponse)
|
||||
async checkUsername(@Args() { username }: CheckUsernameArgs): Promise<CheckUsernameResponse> {
|
||||
@Query(() => Boolean)
|
||||
async checkUsername(@Args() { username }: CheckUsernameArgs): Promise<Boolean> {
|
||||
// Username empty?
|
||||
if (username === '') {
|
||||
throw new Error('Username must be set.')
|
||||
@ -296,7 +295,7 @@ export class UserResolver {
|
||||
throw new Error(`Username "${username}" already taken.`)
|
||||
}
|
||||
|
||||
return new CheckUsernameResponse({ state: 'success' })
|
||||
return true
|
||||
}
|
||||
|
||||
@Query(() => CheckEmailResponse)
|
||||
|
||||
@ -75,9 +75,7 @@ export const sendResetPasswordEmail = gql`
|
||||
|
||||
export const checkUsername = gql`
|
||||
query($username: String!) {
|
||||
checkUsername(username: $username) {
|
||||
state
|
||||
}
|
||||
checkUsername(username: $username)
|
||||
}
|
||||
`
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ export const loadAllRules = (i18nCallback) => {
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
return result.data.checkUsername.state === 'success'
|
||||
return result.data.checkUsername
|
||||
})
|
||||
.catch(() => {
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user