feat(auth): login screen and domain-scoped navigation
Session login against /auth/*, with a guard on every route and an interceptor that returns to the login on 401. The header, the import workspace and both governance panels only offer the account's own domains (auth/dominios.ts), and a batch opens on the account's database. The sign-in screen follows the app's palette: logo above the title, the action button in the shared tokens, and no register or password-recovery rows.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
/**
|
||||
* Helpers for the screens that list domains (cargar información, gobernanza):
|
||||
* an account only ever sees its own, and «Todos» only belongs to one that
|
||||
* reaches every domain — the administrator.
|
||||
*/
|
||||
|
||||
/** De la lista dada, las entradas cuyo dominio alcanza la cuenta. */
|
||||
export function dominiosPermitidos<T extends { id: string }>(auth: AuthService, dominios: readonly T[]): T[] {
|
||||
return dominios.filter((dominio) => auth.puedeVer(dominio.id));
|
||||
}
|
||||
|
||||
/** Si la cuenta alcanza todos: solo entonces tiene sentido ofrecer «Todos». */
|
||||
export function alcanzaTodos(auth: AuthService, dominios: readonly { id: string }[]): boolean {
|
||||
return dominios.every((dominio) => auth.puedeVer(dominio.id));
|
||||
}
|
||||
|
||||
/**
|
||||
* El dominio con el que abre una pantalla: el único que alcanza la cuenta, o
|
||||
* `null` («Todos») cuando alcanza varios. Sin sesión resuelta devuelve `null`,
|
||||
* que es el comportamiento de siempre.
|
||||
*/
|
||||
export function dominioInicial<T extends string>(auth: AuthService, dominios: readonly { id: T }[]): T | null {
|
||||
const propios = dominiosPermitidos(auth, dominios);
|
||||
return propios.length === 1 ? propios[0].id : null;
|
||||
}
|
||||
Reference in New Issue
Block a user