From af1fdad0458f85819e84f7e130d41de3d3f34790 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Fri, 13 Oct 2023 13:34:40 -0500 Subject: [PATCH] Updated user function --- netlify/functions/users/users.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/netlify/functions/users/users.ts b/netlify/functions/users/users.ts index 0c84950..312fcc7 100644 --- a/netlify/functions/users/users.ts +++ b/netlify/functions/users/users.ts @@ -38,7 +38,7 @@ export const handler: Handler = async (event: HandlerEvent, context: HandlerCont const data = await response.data; if (response.status == 201) { const response2 = await axios.put( - baseurl + '_users', + baseurl + '_users/org.couchdb.user:' + dbKey, {_id: 'org.couchdb.user:' + dbKey, name: dbKey, password: password, roles: [], type: 'user'}, { headers: { @@ -48,6 +48,16 @@ export const handler: Handler = async (event: HandlerEvent, context: HandlerCont } }); data.auth = response2.data; + const authresponse = await axios.put( + baseurl + dbKey + '/_security', + {admins: {names: [], roles: []}, members: {names: [dbKey], roles: []}}, + { + headers: { + 'Authorization': 'Basic ' + authToken, + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }); } return { headers: {