mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-22 16:16:46 +02:00
Merge 7bbb4a4b7b
into 549c445853
This commit is contained in:
commit
bb950ef671
|
@ -512,4 +512,5 @@ module.exports = {
|
|||
// server window, displayed on the client.
|
||||
raw: false,
|
||||
},
|
||||
authModule: "local",
|
||||
};
|
||||
|
|
|
@ -111,6 +111,7 @@ export type ConfigType = {
|
|||
ldap: Ldap;
|
||||
debug: Debug;
|
||||
themeColor: string;
|
||||
authModule: string;
|
||||
};
|
||||
|
||||
class Config {
|
||||
|
|
|
@ -2,6 +2,8 @@ import colors from "chalk";
|
|||
import Client from "../client";
|
||||
import ClientManager from "../clientManager";
|
||||
import log from "../log";
|
||||
import Auth from "./packages";
|
||||
import Config from "../config";
|
||||
|
||||
export type AuthHandler = (
|
||||
manager: ClientManager,
|
||||
|
@ -35,17 +37,21 @@ const toExport = {
|
|||
}
|
||||
|
||||
// Override default API stubs with exports from first enabled plugin found
|
||||
const resolvedPlugins = await Promise.all(plugins);
|
||||
const packagePlugins = [...Auth.packageMap.values()]
|
||||
.map((packagee) => packagee.auth || [])
|
||||
.flatMap((item) => item);
|
||||
|
||||
for (const {default: plugin} of resolvedPlugins) {
|
||||
if (plugin.isEnabled()) {
|
||||
toExport.initialized = true;
|
||||
const resolvedPlugins = (await Promise.all(plugins))
|
||||
.map((plugin) => plugin.default)
|
||||
.concat(packagePlugins);
|
||||
|
||||
for (const name in plugin) {
|
||||
toExport[name] = plugin[name];
|
||||
}
|
||||
const plugin = resolvedPlugins.find(
|
||||
(resolvedPlugin) => resolvedPlugin.moduleName === Config.values.authModule
|
||||
);
|
||||
|
||||
break;
|
||||
if (plugin) {
|
||||
for (const name in plugin) {
|
||||
toExport[name] = plugin[name];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,9 +10,17 @@ import inputs from "../inputs";
|
|||
import fs from "fs";
|
||||
import Utils from "../../command-line/utils";
|
||||
import Client from "../../client";
|
||||
import {AuthHandler} from "../auth";
|
||||
|
||||
type Package = {
|
||||
onServerStart: (packageApis: any) => void;
|
||||
auth?: [
|
||||
{
|
||||
moduleName: string;
|
||||
auth: AuthHandler;
|
||||
isEnabled: () => boolean;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
const packageMap = new Map<string, Package>();
|
||||
|
@ -44,6 +52,7 @@ export default {
|
|||
getPackage,
|
||||
loadPackages,
|
||||
outdated,
|
||||
packageMap,
|
||||
};
|
||||
|
||||
// TODO: verify binds worked. Used to be 'this' instead of 'packageApis'
|
||||
|
|
Loading…
Reference in a new issue