@kne/fastify-oidc 0.1.11 → 0.1.12
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { mapTenantImages } = require('../utils/tenant-images');
|
|
2
|
+
const findMirroredFile = require('../utils/find-mirrored-file');
|
|
2
3
|
|
|
3
4
|
const FAILURE_RETRY_MS = 30 * 1000;
|
|
4
5
|
const FILE_SOURCE = 'oidcHostFileSource';
|
|
@@ -54,7 +55,7 @@ module.exports = ({ fastify, options, serviceClient, userMirror }) => {
|
|
|
54
55
|
const mapping = {};
|
|
55
56
|
for (const [source, url] of Object.entries(fileUrls)) {
|
|
56
57
|
const current = previous[source];
|
|
57
|
-
if (
|
|
58
|
+
if (await findMirroredFile(files, current)) {
|
|
58
59
|
mapping[source] = current;
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const crypto = require('node:crypto');
|
|
2
2
|
const { pick } = require('lodash');
|
|
3
|
+
const findMirroredFile = require('../utils/find-mirrored-file');
|
|
3
4
|
|
|
4
5
|
const PROFILE_FIELDS = ['nickname', 'avatar', 'email', 'phone', 'gender', 'birthday', 'description'];
|
|
5
6
|
const USER_FIELDS = ['id', ...PROFILE_FIELDS, 'status'];
|
|
@@ -22,7 +23,7 @@ module.exports = ({ fastify, options, serviceClient }) => {
|
|
|
22
23
|
if (!remote.avatar) {
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
25
|
-
const mirrored =
|
|
26
|
+
const mirrored = await findMirroredFile(files, current);
|
|
26
27
|
const mirroredSource = mirrored?.options?.[AVATAR_SOURCE];
|
|
27
28
|
if (mirroredSource && mirroredSource === remote.avatar) {
|
|
28
29
|
return current;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 找已拷到本地文件库的文件:记录还在但文件已丢(本地存储随部署目录变化丢失)时视为没有,调用方重新拷贝
|
|
3
|
+
*/
|
|
4
|
+
module.exports = async (files, id) => {
|
|
5
|
+
if (!id) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const file = await Promise.resolve(files.getFileInstance({ id })).catch(() => null);
|
|
9
|
+
if (!file || typeof files.getFileUrl !== 'function') {
|
|
10
|
+
return file;
|
|
11
|
+
}
|
|
12
|
+
const available = await Promise.resolve(files.getFileUrl({ id })).then(
|
|
13
|
+
() => true,
|
|
14
|
+
() => false
|
|
15
|
+
);
|
|
16
|
+
return available ? file : null;
|
|
17
|
+
};
|