@@ -328,6 +328,45 @@ delete_auto_service_user() {
328
328
echo " $PARSED_RESPONSE "
329
329
}
330
330
331
+ delete_default_zitadel_admin () {
332
+ INSTANCE_URL=$1
333
+ PAT=$2
334
+
335
+ # Search for the default zitadel-admin user
336
+ RESPONSE=$(
337
+ curl -sS -X POST " $INSTANCE_URL /management/v1/users/_search" \
338
+ -H " Authorization: Bearer $PAT " \
339
+ -H " Content-Type: application/json" \
340
+ -d ' {
341
+ "queries": [
342
+ {
343
+ "userNameQuery": {
344
+ "userName": "zitadel-admin@",
345
+ "method": "TEXT_QUERY_METHOD_STARTS_WITH"
346
+ }
347
+ }
348
+ ]
349
+ }'
350
+ )
351
+
352
+ DEFAULT_ADMIN_ID=$( echo " $RESPONSE " | jq -r ' .result[0].id // empty' )
353
+
354
+ if [ -n " $DEFAULT_ADMIN_ID " ] && [ " $DEFAULT_ADMIN_ID " != " null" ]; then
355
+ echo " Found default zitadel-admin user with ID: $DEFAULT_ADMIN_ID "
356
+
357
+ RESPONSE=$(
358
+ curl -sS -X DELETE " $INSTANCE_URL /management/v1/users/$DEFAULT_ADMIN_ID " \
359
+ -H " Authorization: Bearer $PAT " \
360
+ -H " Content-Type: application/json" \
361
+ )
362
+ PARSED_RESPONSE=$( echo " $RESPONSE " | jq -r ' .details.changeDate // "deleted"' )
363
+ handle_zitadel_request_response " $PARSED_RESPONSE " " delete_default_zitadel_admin" " $RESPONSE "
364
+
365
+ else
366
+ echo " Default zitadel-admin user not found: $RESPONSE "
367
+ fi
368
+ }
369
+
331
370
init_zitadel () {
332
371
echo -e " \nInitializing Zitadel with NetBird's applications\n"
333
372
INSTANCE_URL=" $NETBIRD_HTTP_PROTOCOL ://$NETBIRD_DOMAIN "
@@ -346,6 +385,9 @@ init_zitadel() {
346
385
echo -n " Waiting for Zitadel to become ready "
347
386
wait_api " $INSTANCE_URL " " $PAT "
348
387
388
+ echo " Deleting default zitadel-admin user..."
389
+ delete_default_zitadel_admin " $INSTANCE_URL " " $PAT "
390
+
349
391
# create the zitadel project
350
392
echo " Creating new zitadel project"
351
393
PROJECT_ID=$( create_new_project " $INSTANCE_URL " " $PAT " )
0 commit comments