From dfdf4d9f5cd6c778407c7ee06e520a12c047e2c0 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Sat, 23 Dec 2023 07:09:19 -0500 Subject: [PATCH] dont crash on user already exists error --- docker/oidc/mock-oidc-provider/start-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/oidc/mock-oidc-provider/start-server.sh b/docker/oidc/mock-oidc-provider/start-server.sh index 00c7c6a..b654b68 100755 --- a/docker/oidc/mock-oidc-provider/start-server.sh +++ b/docker/oidc/mock-oidc-provider/start-server.sh @@ -22,7 +22,7 @@ until nc -z localhost 27017; do sleep 1 done # Creates the OIDC user role in the database. -mongosh "mongodb://localhost:27017/admin" --json --eval "(process.env.OIDC_TOKEN_PAYLOAD_GROUPS ?? 'testgroup').split(',').map(group => db.createRole({ role: 'dev/' + group, privileges: [ ], roles: [ \"readWriteAnyDatabase\" ] }));" +mongosh "mongodb://localhost:27017/admin" --json --eval "try {(process.env.OIDC_TOKEN_PAYLOAD_GROUPS ?? 'testgroup').split(',').map(group => db.createRole({ role: 'dev/' + group, privileges: [ ], roles: [ \"readWriteAnyDatabase\" ] })); } catch (err) { /* The user likely already exists. */ if (!err.message.includes('already exists')) { throw err; } }" # Stop the no auth database (we re-start it with auth enabled next). pkill mongod