refactor: stricter domain: auth

This commit is contained in:
2026-04-11 13:52:59 +02:00
parent 58e338246f
commit 39b85e2e3a
13 changed files with 33 additions and 29 deletions

View File

@@ -10,12 +10,12 @@ export const routes: Routes = [
{
path: 'login',
loadComponent: () =>
import('./domains/auth/feature/login/login.component').then((module) => module.LoginComponent)
import('./domains/authentication/feature/login/login.component').then((module) => module.LoginComponent)
},
{
path: 'register',
loadComponent: () =>
import('./domains/auth/feature/register/register.component').then((module) => module.RegisterComponent)
import('./domains/authentication/feature/register/register.component').then((module) => module.RegisterComponent)
},
{
path: 'invite/:inviteId',

View File

@@ -10,7 +10,7 @@ infrastructure adapters and UI.
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
| **attachment** | File upload/download, chunk transfer, persistence | `AttachmentFacade` |
| **access-control** | Role, permission, ban matching, moderation, and room access rules | `normalizeRoomAccessControl()`, `resolveRoomPermission()`, `hasRoomBanForUser()` |
| **auth** | Login / register HTTP orchestration, user-bar UI | `AuthService` |
| **authentication** | Login / register HTTP orchestration, user-bar UI | `AuthenticationService` |
| **chat** | Messaging rules, sync logic, GIF/Klipy integration, chat UI | `KlipyService`, `canEditMessage()`, `ChatMessagesComponent` |
| **notifications** | Notification preferences, unread tracking, desktop alert orchestration | `NotificationsFacade` |
| **screen-share** | Source picker, quality presets | `ScreenShareFacade` |
@@ -25,7 +25,7 @@ The larger domains also keep longer design notes in their own folders:
- [attachment/README.md](attachment/README.md)
- [access-control/README.md](access-control/README.md)
- [auth/README.md](auth/README.md)
- [authentication/README.md](authentication/README.md)
- [chat/README.md](chat/README.md)
- [notifications/README.md](notifications/README.md)
- [screen-share/README.md](screen-share/README.md)

View File

@@ -1 +0,0 @@
export * from './application/auth.service';

View File

@@ -1,13 +1,16 @@
# Auth Domain
# Authentication Domain
Handles user authentication (login and registration) against the configured server endpoint. Provides the login, register, and user-bar UI components.
## Module map
```
auth/
authentication/
├── application/
│ └── auth.service.ts HTTP login/register against the active server endpoint
│ └── authentication.service.ts HTTP login/register against the active server endpoint
├── domain/
│ └── authentication.model.ts LoginResponse interface
├── feature/
│ ├── login/ Login form component
@@ -19,14 +22,14 @@ auth/
## Service overview
`AuthService` resolves the API base URL from `ServerDirectoryFacade`, then makes POST requests for login and registration. It does not hold session state itself; after a successful login the calling component stores `currentUserId` in localStorage and dispatches `UsersActions.setCurrentUser` into the NgRx store.
`AuthenticationService` resolves the API base URL from `ServerDirectoryFacade`, then makes POST requests for login and registration. It does not hold session state itself; after a successful login the calling component stores `currentUserId` in localStorage and dispatches `UsersActions.setCurrentUser` into the NgRx store.
```mermaid
graph TD
Login[LoginComponent]
Register[RegisterComponent]
UserBar[UserBarComponent]
Auth[AuthService]
Auth[AuthenticationService]
SD[ServerDirectoryFacade]
Store[NgRx Store]
@@ -36,7 +39,7 @@ graph TD
Auth --> SD
Login --> Store
click Auth "application/auth.service.ts" "HTTP login/register" _blank
click Auth "application/authentication.service.ts" "HTTP login/register" _blank
click Login "feature/login/" "Login form" _blank
click Register "feature/register/" "Registration form" _blank
click UserBar "feature/user-bar/" "Current user display" _blank
@@ -49,7 +52,7 @@ graph TD
sequenceDiagram
participant User
participant Login as LoginComponent
participant Auth as AuthService
participant Auth as AuthenticationService
participant SD as ServerDirectoryFacade
participant API as Server API
participant Store as NgRx Store

View File

@@ -3,18 +3,7 @@ import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { type ServerEndpoint, ServerDirectoryFacade } from '../../server-directory';
/**
* Response returned by the authentication endpoints (login / register).
*/
export interface LoginResponse {
/** Unique user identifier assigned by the server. */
id: string;
/** Login username. */
username: string;
/** Human-readable display name. */
displayName: string;
}
import type { LoginResponse } from '../domain/authentication.model';
/**
* Handles user authentication (login and registration) against a
@@ -25,7 +14,7 @@ export interface LoginResponse {
* server endpoint is used.
*/
@Injectable({ providedIn: 'root' })
export class AuthService {
export class AuthenticationService {
private readonly http = inject(HttpClient);
private readonly serverDirectory = inject(ServerDirectoryFacade);

View File

@@ -0,0 +1,11 @@
/**
* Response returned by the authentication endpoints (login / register).
*/
export interface LoginResponse {
/** Unique user identifier assigned by the server. */
id: string;
/** Login username. */
username: string;
/** Human-readable display name. */
displayName: string;
}

View File

@@ -11,7 +11,7 @@ import { Store } from '@ngrx/store';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideLogIn } from '@ng-icons/lucide';
import { AuthService } from '../../application/auth.service';
import { AuthenticationService } from '../../application/authentication.service';
import { ServerDirectoryFacade } from '../../../server-directory';
import { UsersActions } from '../../../../store/users/users.actions';
import { User } from '../../../../shared-kernel';
@@ -40,7 +40,7 @@ export class LoginComponent {
serverId: string | undefined = this.serversSvc.activeServer()?.id;
error = signal<string | null>(null);
private auth = inject(AuthService);
private auth = inject(AuthenticationService);
private store = inject(Store);
private route = inject(ActivatedRoute);
private router = inject(Router);

View File

@@ -11,7 +11,7 @@ import { Store } from '@ngrx/store';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideUserPlus } from '@ng-icons/lucide';
import { AuthService } from '../../application/auth.service';
import { AuthenticationService } from '../../application/authentication.service';
import { ServerDirectoryFacade } from '../../../server-directory';
import { UsersActions } from '../../../../store/users/users.actions';
import { User } from '../../../../shared-kernel';
@@ -41,7 +41,7 @@ export class RegisterComponent {
serverId: string | undefined = this.serversSvc.activeServer()?.id;
error = signal<string | null>(null);
private auth = inject(AuthService);
private auth = inject(AuthenticationService);
private store = inject(Store);
private route = inject(ActivatedRoute);
private router = inject(Router);

View File

@@ -0,0 +1,2 @@
export * from './application/authentication.service';
export * from './domain/authentication.model';