strapi-plugin-oidc 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -8
- package/dist/server/index.js +8 -8
- package/dist/server/index.mjs +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -140,14 +140,10 @@ API calls write directly to the database — there is no unsaved state.
|
|
|
140
140
|
|
|
141
141
|
### Import format
|
|
142
142
|
|
|
143
|
-
Accepted by both the API import endpoint and the Admin UI import button.
|
|
143
|
+
Accepted by both the API import endpoint and the Admin UI import button. If the email already exists as a Strapi admin user, their current roles are used automatically.
|
|
144
144
|
|
|
145
145
|
```json
|
|
146
|
-
[
|
|
147
|
-
{ "email": "alice@example.com", "roles": ["Editor"] },
|
|
148
|
-
{ "email": "bob@example.com", "roles": ["Editor", "Author"] },
|
|
149
|
-
{ "email": "carol@example.com" }
|
|
150
|
-
]
|
|
146
|
+
[{ "email": "alice@example.com" }, { "email": "bob@example.com" }]
|
|
151
147
|
```
|
|
152
148
|
|
|
153
149
|
Duplicate emails within the payload and emails already in the whitelist are silently skipped.
|
|
@@ -166,12 +162,12 @@ curl -H "Authorization: Bearer <token>" \
|
|
|
166
162
|
|
|
167
163
|
# Add
|
|
168
164
|
curl -X POST -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
|
|
169
|
-
-d '{"email": "user@example.com"
|
|
165
|
+
-d '{"email": "user@example.com"}' \
|
|
170
166
|
http://localhost:1337/api/strapi-plugin-oidc/whitelist
|
|
171
167
|
|
|
172
168
|
# Bulk import
|
|
173
169
|
curl -X POST -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
|
|
174
|
-
-d '{"users": [{"email": "a@example.com"
|
|
170
|
+
-d '{"users": [{"email": "a@example.com"}, {"email": "b@example.com"}]}' \
|
|
175
171
|
http://localhost:1337/api/strapi-plugin-oidc/whitelist/import
|
|
176
172
|
|
|
177
173
|
# Delete one (by email)
|
package/dist/server/index.js
CHANGED
|
@@ -834,9 +834,9 @@ async function register(ctx) {
|
|
|
834
834
|
ctx.body = { matchedExistingUsersCount };
|
|
835
835
|
}
|
|
836
836
|
async function removeEmail(ctx) {
|
|
837
|
-
const {
|
|
837
|
+
const { email } = ctx.params;
|
|
838
838
|
const whitelistService2 = getWhitelistService();
|
|
839
|
-
await whitelistService2.removeUser(
|
|
839
|
+
await whitelistService2.removeUser(email);
|
|
840
840
|
ctx.body = {};
|
|
841
841
|
}
|
|
842
842
|
async function deleteAll(ctx) {
|
|
@@ -880,7 +880,7 @@ async function syncUsers(ctx) {
|
|
|
880
880
|
const currentUsersByEmail = new Map(currentUsers.map((u) => [u.email, u]));
|
|
881
881
|
for (const currUser of currentUsers) {
|
|
882
882
|
if (!syncEmailSet.has(currUser.email)) {
|
|
883
|
-
await whitelistService2.removeUser(currUser.
|
|
883
|
+
await whitelistService2.removeUser(currUser.email);
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
for (const email of emails) {
|
|
@@ -1063,7 +1063,7 @@ const routes = {
|
|
|
1063
1063
|
},
|
|
1064
1064
|
{
|
|
1065
1065
|
method: "DELETE",
|
|
1066
|
-
path: "/whitelist/:
|
|
1066
|
+
path: "/whitelist/:email",
|
|
1067
1067
|
handler: "whitelist.removeEmail",
|
|
1068
1068
|
config: adminPolicies("update")
|
|
1069
1069
|
},
|
|
@@ -1122,7 +1122,7 @@ const routes = {
|
|
|
1122
1122
|
},
|
|
1123
1123
|
{
|
|
1124
1124
|
method: "DELETE",
|
|
1125
|
-
path: "/whitelist/:
|
|
1125
|
+
path: "/whitelist/:email",
|
|
1126
1126
|
handler: "whitelist.removeEmail"
|
|
1127
1127
|
},
|
|
1128
1128
|
{
|
|
@@ -1524,9 +1524,9 @@ function whitelistService({ strapi: strapi2 }) {
|
|
|
1524
1524
|
data: { email }
|
|
1525
1525
|
});
|
|
1526
1526
|
},
|
|
1527
|
-
async removeUser(
|
|
1528
|
-
await
|
|
1529
|
-
where: {
|
|
1527
|
+
async removeUser(email) {
|
|
1528
|
+
await strapi2.db.query("plugin::strapi-plugin-oidc.whitelists").deleteMany({
|
|
1529
|
+
where: { email }
|
|
1530
1530
|
});
|
|
1531
1531
|
},
|
|
1532
1532
|
async checkWhitelistForEmail(email) {
|
package/dist/server/index.mjs
CHANGED
|
@@ -828,9 +828,9 @@ async function register(ctx) {
|
|
|
828
828
|
ctx.body = { matchedExistingUsersCount };
|
|
829
829
|
}
|
|
830
830
|
async function removeEmail(ctx) {
|
|
831
|
-
const {
|
|
831
|
+
const { email } = ctx.params;
|
|
832
832
|
const whitelistService2 = getWhitelistService();
|
|
833
|
-
await whitelistService2.removeUser(
|
|
833
|
+
await whitelistService2.removeUser(email);
|
|
834
834
|
ctx.body = {};
|
|
835
835
|
}
|
|
836
836
|
async function deleteAll(ctx) {
|
|
@@ -874,7 +874,7 @@ async function syncUsers(ctx) {
|
|
|
874
874
|
const currentUsersByEmail = new Map(currentUsers.map((u) => [u.email, u]));
|
|
875
875
|
for (const currUser of currentUsers) {
|
|
876
876
|
if (!syncEmailSet.has(currUser.email)) {
|
|
877
|
-
await whitelistService2.removeUser(currUser.
|
|
877
|
+
await whitelistService2.removeUser(currUser.email);
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
for (const email of emails) {
|
|
@@ -1057,7 +1057,7 @@ const routes = {
|
|
|
1057
1057
|
},
|
|
1058
1058
|
{
|
|
1059
1059
|
method: "DELETE",
|
|
1060
|
-
path: "/whitelist/:
|
|
1060
|
+
path: "/whitelist/:email",
|
|
1061
1061
|
handler: "whitelist.removeEmail",
|
|
1062
1062
|
config: adminPolicies("update")
|
|
1063
1063
|
},
|
|
@@ -1116,7 +1116,7 @@ const routes = {
|
|
|
1116
1116
|
},
|
|
1117
1117
|
{
|
|
1118
1118
|
method: "DELETE",
|
|
1119
|
-
path: "/whitelist/:
|
|
1119
|
+
path: "/whitelist/:email",
|
|
1120
1120
|
handler: "whitelist.removeEmail"
|
|
1121
1121
|
},
|
|
1122
1122
|
{
|
|
@@ -1518,9 +1518,9 @@ function whitelistService({ strapi: strapi2 }) {
|
|
|
1518
1518
|
data: { email }
|
|
1519
1519
|
});
|
|
1520
1520
|
},
|
|
1521
|
-
async removeUser(
|
|
1522
|
-
await
|
|
1523
|
-
where: {
|
|
1521
|
+
async removeUser(email) {
|
|
1522
|
+
await strapi2.db.query("plugin::strapi-plugin-oidc.whitelists").deleteMany({
|
|
1523
|
+
where: { email }
|
|
1524
1524
|
});
|
|
1525
1525
|
},
|
|
1526
1526
|
async checkWhitelistForEmail(email) {
|
package/package.json
CHANGED