|
@@ -41,14 +41,15 @@ func (r *mutationResolver) CustomerCreate(
|
|
return response, err
|
|
return response, err
|
|
}
|
|
}
|
|
|
|
|
|
- if ls, err := r.client.GetUsers(ctx, admin.AccessToken, r.conf.Cli.Realm, gocloak.GetUsersParams{
|
|
|
|
|
|
+ if count, err := r.client.GetUserCount(ctx, admin.AccessToken, r.conf.Cli.Realm, gocloak.GetUsersParams{
|
|
Email: gocloak.StringP(input.Email),
|
|
Email: gocloak.StringP(input.Email),
|
|
- }); err != nil {
|
|
|
|
- response.CustomerUserErrors = append(response.CustomerUserErrors,
|
|
|
|
- CustomerError(generated.CustomerErrorCodeBlank, err))
|
|
|
|
- } else if len(ls) > 0 {
|
|
|
|
|
|
+ }); err != nil || count > 0 {
|
|
|
|
+ if count > 0 {
|
|
|
|
+ err = fmt.Errorf("email has been already registered")
|
|
|
|
+ }
|
|
|
|
+
|
|
response.CustomerUserErrors = append(response.CustomerUserErrors,
|
|
response.CustomerUserErrors = append(response.CustomerUserErrors,
|
|
- CustomerError(generated.CustomerErrorCodeTaken, fmt.Errorf("email has been already registered"), "email"))
|
|
|
|
|
|
+ CustomerError(generated.CustomerErrorCodeTaken, err, "email"))
|
|
}
|
|
}
|
|
|
|
|
|
if len(response.CustomerUserErrors) > 0 {
|
|
if len(response.CustomerUserErrors) > 0 {
|