added auth strategies migration, fixed rebuild of modules on migrations

This commit is contained in:
dswbx
2025-02-27 10:08:22 +01:00
parent 7743f71a11
commit dd48962901
10 changed files with 854 additions and 33 deletions

View File

@@ -7,7 +7,7 @@ import {
type Strategy,
} from "auth";
import type { PasswordStrategy } from "auth/authenticate/strategies";
import { type DB, Exception, type PrimaryFieldType } from "core";
import { $console, type DB, Exception, type PrimaryFieldType } from "core";
import { type Static, secureRandomString, transformObject } from "core/utils";
import type { Entity, EntityManager } from "data";
import { type FieldSchema, em, entity, enumm, text } from "data/prototype";
@@ -41,6 +41,12 @@ export class AppAuth extends Module<typeof authConfigSchema> {
}
}
// @todo: password strategy is required atm
if (!to.strategies?.password?.enabled) {
$console.warn("Password strategy cannot be disabled.");
to.strategies!.password!.enabled = true;
}
return to;
}
@@ -89,6 +95,9 @@ export class AppAuth extends Module<typeof authConfigSchema> {
isStrategyEnabled(strategy: Strategy | string) {
const name = typeof strategy === "string" ? strategy : strategy.getName();
// for now, password is always active
if (name === "password") return true;
return this.config.strategies?.[name]?.enabled ?? false;
}