mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 16:10:07 +00:00
Give three more admin surfaces back to the domains that own them
default-user-settings, notification-preferences and oidc leave AdminController. The first two were pure pass-throughs on AdminService that did nothing but forward and cast; the third had its SQL there for a domain that already had a module of its own. AdminService loses SettingsService and NotificationPreferencesService entirely. Two things came out of the move rather than going into it. The OIDC lockout guard now has tests. It refuses to clear the SSO config while password login is disabled — otherwise the instance has no SSO to log in through and no password form either — and nothing covered that branch before, because it sat among admin tests that only exercised the happy path. The admin e2e app had to learn about the split. It assembles AdminModule alone, so the moved routes 404'd there while working in production; it now imports the three domains too. That is the same failure mode the module-provider guards catch for RPC classes, and it is worth knowing that an e2e app which builds a subset will find it first. Also fixes the audit route note: audit-log stays on AdminController on purpose. AuthModule imports AuditModule, so an admin-gated controller in AuditModule closes a cycle — the same trap the addons toggles hit.
This commit is contained in:
@@ -22,6 +22,9 @@ import {
|
||||
NotificationRespondDto,
|
||||
} from './notifications.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { AdminGuard } from '../auth/admin.guard';
|
||||
import { NotificationPreferencesService } from './notification-preferences.service';
|
||||
import { AdminNotificationPreferencesDto } from '../admin/admin.dto';
|
||||
import { CurrentUser } from '../auth/current-user.decorator';
|
||||
|
||||
// The masked placeholder the client sends instead of a stored secret (8× U+2022).
|
||||
@@ -199,3 +202,30 @@ export class NotificationsController {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /api/admin/notification-preferences — the admin-scope row of the preference matrix.
|
||||
*
|
||||
* Two routes that sat on AdminController and reached NotificationPreferencesService
|
||||
* through a pair of pass-through methods on AdminService. The owner is here; the
|
||||
* 'admin' scope argument they always passed is now written once, at the only place
|
||||
* that uses it.
|
||||
*/
|
||||
@Controller('api/admin/notification-preferences')
|
||||
@UseGuards(JwtAuthGuard, AdminGuard)
|
||||
export class AdminNotificationPreferencesController {
|
||||
constructor(private readonly prefs: NotificationPreferencesService) {}
|
||||
|
||||
@Get()
|
||||
get(@CurrentUser() user: User) {
|
||||
return this.prefs.getPreferencesMatrix(user.id, user.role, 'admin');
|
||||
}
|
||||
|
||||
@Put()
|
||||
set(@CurrentUser() user: User, @Body() body: AdminNotificationPreferencesDto) {
|
||||
this.prefs.setAdminPreferences(user.id, body);
|
||||
// Answer with the refreshed matrix rather than the raw write result — the admin
|
||||
// panel renders straight from this response.
|
||||
return this.prefs.getPreferencesMatrix(user.id, user.role, 'admin');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user