+
{{state?.username}}
{{state?.roleIdentifier}}
diff --git a/src/app/core/components/navigation/navigation.component.ts b/src/app/core/components/navigation/navigation.component.ts
index 481ce3a..2fda3e7 100644
--- a/src/app/core/components/navigation/navigation.component.ts
+++ b/src/app/core/components/navigation/navigation.component.ts
@@ -4,6 +4,7 @@ import { AuthService } from '../../services/auth.service';
import { UserStateResponse } from '../../models/user-state-request.model';
import { Router } from '@angular/router';
import { filter, map } from 'rxjs';
+import { AppService } from '../../services/app.service';
@Component({
selector: 'app-navigation',
@@ -13,11 +14,14 @@ import { filter, map } from 'rxjs';
export class NavigationComponent implements OnInit {
state: UserStateResponse | undefined | null;
+ darkMode: boolean;
constructor(
private authService: AuthService,
+ private appService: AppService,
private router: Router,
) {
+ this.darkMode = this.appService.darkMode;
this.state = this.authService.currentState$.value;
this.authService.currentState$.pipe(
filter(state => state === undefined)
@@ -33,4 +37,9 @@ export class NavigationComponent implements OnInit {
logout(): void {
this.authService.logout();
}
+
+ toggleDarkmode() {
+ this.appService.toggleDarkMode();
+ this.darkMode = this.appService.darkMode;
+ }
}
diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts
index 7b4ea58..e72b81f 100644
--- a/src/app/core/core.module.ts
+++ b/src/app/core/core.module.ts
@@ -5,6 +5,8 @@ import { NavigationComponent } from './components/navigation/navigation.componen
import { AuthGuard } from './guards/auth.guard';
import { AuthService } from './services/auth.service';
import { RequestService } from './services/request.service';
+import { AppService } from './services/app.service';
+import { SharedModule } from '../shared/shared.module';
@@ -12,8 +14,9 @@ import { RequestService } from './services/request.service';
declarations: [HomeComponent, NavigationComponent],
exports: [HomeComponent, NavigationComponent],
imports: [
- CommonModule
+ CommonModule,
+ SharedModule
],
- providers: [AuthGuard, AuthService, RequestService]
+ providers: [AuthGuard, AuthService, RequestService, AppService]
})
export class CoreModule { }
diff --git a/src/app/core/models/confirm-registration-request.model.ts b/src/app/core/models/confirm-registration-request.model.ts
new file mode 100644
index 0000000..8167c09
--- /dev/null
+++ b/src/app/core/models/confirm-registration-request.model.ts
@@ -0,0 +1,14 @@
+export interface ConfirmRegistrationRequest {
+ id: string,
+ password: string,
+ passwordConfirmation: string,
+}
+
+export interface ConfirmRegistrationResponse {
+ id: string,
+ username: string,
+ roleIdentifier: string,
+ createdAt: string,
+ updatedAt: string,
+ permissions: string[]
+}
\ No newline at end of file
diff --git a/src/app/core/models/register-user-request.model.ts b/src/app/core/models/register-user-request.model.ts
new file mode 100644
index 0000000..422369e
--- /dev/null
+++ b/src/app/core/models/register-user-request.model.ts
@@ -0,0 +1,7 @@
+export interface RegisterUserRequest {
+ mail: string,
+ username: string,
+}
+
+export interface RegisterUserResponse {
+}
\ No newline at end of file
diff --git a/src/app/core/services/app.service.ts b/src/app/core/services/app.service.ts
new file mode 100644
index 0000000..1177ed6
--- /dev/null
+++ b/src/app/core/services/app.service.ts
@@ -0,0 +1,30 @@
+import { Injectable } from "@angular/core";
+
+@Injectable()
+export class AppService {
+
+ darkMode: boolean;
+
+ constructor(
+ ) {
+ this.darkMode = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);
+ this.applyDarkMode();
+ }
+
+ private applyDarkMode(): void {
+ if (this.darkMode) {
+ document.documentElement.classList.add('theme-dark');
+ } else {
+ document.documentElement.classList.remove('theme-dark');
+ }
+ }
+
+ toggleDarkMode() {
+ this.darkMode = !this.darkMode;
+ this.applyDarkMode();
+ }
+
+ getDarkMode(): boolean {
+ return this.darkMode;
+ }
+}
\ No newline at end of file
diff --git a/src/app/core/services/auth.service.ts b/src/app/core/services/auth.service.ts
index c7c7e7a..209e48d 100644
--- a/src/app/core/services/auth.service.ts
+++ b/src/app/core/services/auth.service.ts
@@ -4,6 +4,8 @@ import { UserStateResponse } from "../models/user-state-request.model";
import { BehaviorSubject, Observable } from "rxjs";
import { LoginRequest, LoginResponse } from "../models/login-request.model copy";
import { Router } from "@angular/router";
+import { RegisterUserRequest, RegisterUserResponse } from "../models/register-user-request.model";
+import { ConfirmRegistrationRequest, ConfirmRegistrationResponse } from "../models/confirm-registration-request.model";
@Injectable()
export class AuthService {
@@ -44,6 +46,36 @@ export class AuthService {
return result;
}
+ register(body: RegisterUserRequest): RegisterUserResponse|null {
+ let result = null;
+
+ this.requestService.post(
+ 'auth/register-user',
+ body,
+ (response: LoginResponse) => {
+ result = response;
+ this.readUserState();
+ }
+ );
+
+ return result;
+ }
+
+ confirmRegistration(body: ConfirmRegistrationRequest): ConfirmRegistrationResponse|null {
+ let result = null;
+
+ this.requestService.post(
+ 'auth/confirm-registration',
+ body,
+ (response: LoginResponse) => {
+ result = response;
+ this.readUserState();
+ }
+ );
+
+ return result;
+ }
+
logout(): void {
this.requestService.post(
'auth/logout-user',
diff --git a/src/app/shared/components/card/card.component.html b/src/app/shared/components/card/card.component.html
index 02ae685..56166c9 100644
--- a/src/app/shared/components/card/card.component.html
+++ b/src/app/shared/components/card/card.component.html
@@ -1,29 +1,32 @@
-