@camstack/core 0.1.35 → 0.1.37

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.
@@ -7778,12 +7778,24 @@ var LocalAuthAddon = class extends BaseAddon {
7778
7778
  const userMgmt = {
7779
7779
  listUsers: async () => {
7780
7780
  if (!this.userManager) return [];
7781
- return this.userManager.listAll();
7781
+ const users = await this.userManager.listAll();
7782
+ if (!this.totpManager) return users.map((u) => ({
7783
+ ...u,
7784
+ totpEnabled: false
7785
+ }));
7786
+ const statuses = await Promise.all(users.map((u) => this.totpManager.getStatus(u.id).catch(() => ({ enabled: false }))));
7787
+ return users.map((u, i) => ({
7788
+ ...u,
7789
+ totpEnabled: statuses[i]?.enabled ?? false
7790
+ }));
7782
7791
  },
7783
7792
  createUser: async (input) => {
7784
7793
  if (!this.userManager) throw new Error("User management not available");
7785
7794
  const { passwordHash: _, ...summary } = await this.userManager.create(input);
7786
- return summary;
7795
+ return {
7796
+ ...summary,
7797
+ totpEnabled: false
7798
+ };
7787
7799
  },
7788
7800
  updateUser: async (input) => {
7789
7801
  if (!this.userManager) throw new Error("User management not available");
@@ -7808,7 +7820,13 @@ var LocalAuthAddon = class extends BaseAddon {
7808
7820
  },
7809
7821
  validateCredentials: async (input) => {
7810
7822
  if (!this.userManager) return null;
7811
- return await this.userManager.validateCredentials(input.username, input.password) ?? null;
7823
+ const user = await this.userManager.validateCredentials(input.username, input.password);
7824
+ if (!user) return null;
7825
+ const totpEnabled = this.totpManager ? (await this.totpManager.getStatus(user.id).catch(() => ({ enabled: false }))).enabled : false;
7826
+ return {
7827
+ ...user,
7828
+ totpEnabled
7829
+ };
7812
7830
  },
7813
7831
  listApiKeys: async () => {
7814
7832
  if (!this.apiKeyManager) return [];