refactor: stricter domain: auth
This commit is contained in:
@@ -10,12 +10,12 @@ export const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'login',
|
path: 'login',
|
||||||
loadComponent: () =>
|
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',
|
path: 'register',
|
||||||
loadComponent: () =>
|
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',
|
path: 'invite/:inviteId',
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ infrastructure adapters and UI.
|
|||||||
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------- |
|
||||||
| **attachment** | File upload/download, chunk transfer, persistence | `AttachmentFacade` |
|
| **attachment** | File upload/download, chunk transfer, persistence | `AttachmentFacade` |
|
||||||
| **access-control** | Role, permission, ban matching, moderation, and room access rules | `normalizeRoomAccessControl()`, `resolveRoomPermission()`, `hasRoomBanForUser()` |
|
| **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` |
|
| **chat** | Messaging rules, sync logic, GIF/Klipy integration, chat UI | `KlipyService`, `canEditMessage()`, `ChatMessagesComponent` |
|
||||||
| **notifications** | Notification preferences, unread tracking, desktop alert orchestration | `NotificationsFacade` |
|
| **notifications** | Notification preferences, unread tracking, desktop alert orchestration | `NotificationsFacade` |
|
||||||
| **screen-share** | Source picker, quality presets | `ScreenShareFacade` |
|
| **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)
|
- [attachment/README.md](attachment/README.md)
|
||||||
- [access-control/README.md](access-control/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)
|
- [chat/README.md](chat/README.md)
|
||||||
- [notifications/README.md](notifications/README.md)
|
- [notifications/README.md](notifications/README.md)
|
||||||
- [screen-share/README.md](screen-share/README.md)
|
- [screen-share/README.md](screen-share/README.md)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export * from './application/auth.service';
|
|
||||||
@@ -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.
|
Handles user authentication (login and registration) against the configured server endpoint. Provides the login, register, and user-bar UI components.
|
||||||
|
|
||||||
## Module map
|
## Module map
|
||||||
|
|
||||||
```
|
```
|
||||||
auth/
|
authentication/
|
||||||
├── application/
|
├── 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/
|
├── feature/
|
||||||
│ ├── login/ Login form component
|
│ ├── login/ Login form component
|
||||||
@@ -19,14 +22,14 @@ auth/
|
|||||||
|
|
||||||
## Service overview
|
## 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
|
```mermaid
|
||||||
graph TD
|
graph TD
|
||||||
Login[LoginComponent]
|
Login[LoginComponent]
|
||||||
Register[RegisterComponent]
|
Register[RegisterComponent]
|
||||||
UserBar[UserBarComponent]
|
UserBar[UserBarComponent]
|
||||||
Auth[AuthService]
|
Auth[AuthenticationService]
|
||||||
SD[ServerDirectoryFacade]
|
SD[ServerDirectoryFacade]
|
||||||
Store[NgRx Store]
|
Store[NgRx Store]
|
||||||
|
|
||||||
@@ -36,7 +39,7 @@ graph TD
|
|||||||
Auth --> SD
|
Auth --> SD
|
||||||
Login --> Store
|
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 Login "feature/login/" "Login form" _blank
|
||||||
click Register "feature/register/" "Registration form" _blank
|
click Register "feature/register/" "Registration form" _blank
|
||||||
click UserBar "feature/user-bar/" "Current user display" _blank
|
click UserBar "feature/user-bar/" "Current user display" _blank
|
||||||
@@ -49,7 +52,7 @@ graph TD
|
|||||||
sequenceDiagram
|
sequenceDiagram
|
||||||
participant User
|
participant User
|
||||||
participant Login as LoginComponent
|
participant Login as LoginComponent
|
||||||
participant Auth as AuthService
|
participant Auth as AuthenticationService
|
||||||
participant SD as ServerDirectoryFacade
|
participant SD as ServerDirectoryFacade
|
||||||
participant API as Server API
|
participant API as Server API
|
||||||
participant Store as NgRx Store
|
participant Store as NgRx Store
|
||||||
@@ -3,18 +3,7 @@ import { Injectable, inject } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { type ServerEndpoint, ServerDirectoryFacade } from '../../server-directory';
|
import { type ServerEndpoint, ServerDirectoryFacade } from '../../server-directory';
|
||||||
|
import type { LoginResponse } from '../domain/authentication.model';
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles user authentication (login and registration) against a
|
* Handles user authentication (login and registration) against a
|
||||||
@@ -25,7 +14,7 @@ export interface LoginResponse {
|
|||||||
* server endpoint is used.
|
* server endpoint is used.
|
||||||
*/
|
*/
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AuthService {
|
export class AuthenticationService {
|
||||||
private readonly http = inject(HttpClient);
|
private readonly http = inject(HttpClient);
|
||||||
private readonly serverDirectory = inject(ServerDirectoryFacade);
|
private readonly serverDirectory = inject(ServerDirectoryFacade);
|
||||||
|
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import { Store } from '@ngrx/store';
|
|||||||
import { NgIcon, provideIcons } from '@ng-icons/core';
|
import { NgIcon, provideIcons } from '@ng-icons/core';
|
||||||
import { lucideLogIn } from '@ng-icons/lucide';
|
import { lucideLogIn } from '@ng-icons/lucide';
|
||||||
|
|
||||||
import { AuthService } from '../../application/auth.service';
|
import { AuthenticationService } from '../../application/authentication.service';
|
||||||
import { ServerDirectoryFacade } from '../../../server-directory';
|
import { ServerDirectoryFacade } from '../../../server-directory';
|
||||||
import { UsersActions } from '../../../../store/users/users.actions';
|
import { UsersActions } from '../../../../store/users/users.actions';
|
||||||
import { User } from '../../../../shared-kernel';
|
import { User } from '../../../../shared-kernel';
|
||||||
@@ -40,7 +40,7 @@ export class LoginComponent {
|
|||||||
serverId: string | undefined = this.serversSvc.activeServer()?.id;
|
serverId: string | undefined = this.serversSvc.activeServer()?.id;
|
||||||
error = signal<string | null>(null);
|
error = signal<string | null>(null);
|
||||||
|
|
||||||
private auth = inject(AuthService);
|
private auth = inject(AuthenticationService);
|
||||||
private store = inject(Store);
|
private store = inject(Store);
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
@@ -11,7 +11,7 @@ import { Store } from '@ngrx/store';
|
|||||||
import { NgIcon, provideIcons } from '@ng-icons/core';
|
import { NgIcon, provideIcons } from '@ng-icons/core';
|
||||||
import { lucideUserPlus } from '@ng-icons/lucide';
|
import { lucideUserPlus } from '@ng-icons/lucide';
|
||||||
|
|
||||||
import { AuthService } from '../../application/auth.service';
|
import { AuthenticationService } from '../../application/authentication.service';
|
||||||
import { ServerDirectoryFacade } from '../../../server-directory';
|
import { ServerDirectoryFacade } from '../../../server-directory';
|
||||||
import { UsersActions } from '../../../../store/users/users.actions';
|
import { UsersActions } from '../../../../store/users/users.actions';
|
||||||
import { User } from '../../../../shared-kernel';
|
import { User } from '../../../../shared-kernel';
|
||||||
@@ -41,7 +41,7 @@ export class RegisterComponent {
|
|||||||
serverId: string | undefined = this.serversSvc.activeServer()?.id;
|
serverId: string | undefined = this.serversSvc.activeServer()?.id;
|
||||||
error = signal<string | null>(null);
|
error = signal<string | null>(null);
|
||||||
|
|
||||||
private auth = inject(AuthService);
|
private auth = inject(AuthenticationService);
|
||||||
private store = inject(Store);
|
private store = inject(Store);
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
2
toju-app/src/app/domains/authentication/index.ts
Normal file
2
toju-app/src/app/domains/authentication/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './application/authentication.service';
|
||||||
|
export * from './domain/authentication.model';
|
||||||
Reference in New Issue
Block a user