mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-14 08:47:30 +08:00
fix: change admin USERNAME config
This commit is contained in:
@@ -261,6 +261,27 @@ export async function getConfig(): Promise<AdminConfig> {
|
|||||||
source.from = 'custom';
|
source.from = 'custom';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ownerUser = process.env.USERNAME || '';
|
||||||
|
// 检查配置中的站长用户是否和 USERNAME 匹配,如果不匹配则降级为普通用户
|
||||||
|
let containOwner = false;
|
||||||
|
adminConfig.UserConfig.Users.forEach((user) => {
|
||||||
|
if (user.username !== ownerUser && user.role === 'owner') {
|
||||||
|
user.role = 'user';
|
||||||
|
}
|
||||||
|
if (user.username === ownerUser) {
|
||||||
|
containOwner = true;
|
||||||
|
user.role = 'owner';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 如果不在则添加
|
||||||
|
if (!containOwner) {
|
||||||
|
adminConfig.UserConfig.Users.unshift({
|
||||||
|
username: ownerUser,
|
||||||
|
role: 'owner',
|
||||||
|
});
|
||||||
|
}
|
||||||
cachedConfig = adminConfig;
|
cachedConfig = adminConfig;
|
||||||
} else {
|
} else {
|
||||||
// DB 无配置,执行一次初始化
|
// DB 无配置,执行一次初始化
|
||||||
|
|||||||
Reference in New Issue
Block a user