diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts
index 45036f67..bba4e278 100644
--- a/webapp/src/app/app.routes.ts
+++ b/webapp/src/app/app.routes.ts
@@ -1,7 +1,7 @@
import { Routes } from '@angular/router';
import { AboutComponent } from '@app/about/about.component';
import { HomeComponent } from '@app/home/home.component';
-import { ChatComponent } from '@app/chat/chat/chat.component';
+import { MentorComponent } from '@app/mentor/mentor.component';
import { WorkspaceComponent } from '@app/workspace/workspace.component';
import { UserProfileComponent } from '@app/user/user-profile.component';
import { WorkspaceUsersComponent } from './workspace/users/users.component';
@@ -12,6 +12,7 @@ import { ImprintComponent } from '@app/legal/imprint.component';
import { PrivacyComponent } from '@app/legal/privacy.component';
import { AdminGuard } from '@app/core/security/admin.guard';
import { AuthGuard } from '@app/core/security/auth.guard';
+import { MentorGuard } from '@app/core/security/mentor.guard';
export const routes: Routes = [
// Public routes
@@ -39,7 +40,6 @@ export const routes: Routes = [
{ path: 'settings', component: SettingsComponent },
{ path: 'imprint', component: ImprintComponent },
{ path: 'privacy', component: PrivacyComponent },
- { path: 'chat', component: ChatComponent },
// Protected routes
{
path: '',
@@ -48,6 +48,7 @@ export const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'user/:id', component: UserProfileComponent },
{ path: 'settings', component: SettingsComponent },
+ { path: 'mentor', component: MentorComponent, canActivate: [MentorGuard] },
{ path: 'workspace', component: WorkspaceComponent, canActivate: [AdminGuard] }
]
}
diff --git a/webapp/src/app/core/header/ai-mentor/ai-mentor.component.html b/webapp/src/app/core/header/ai-mentor/ai-mentor.component.html
index 0c7d94c7..f954f88a 100644
--- a/webapp/src/app/core/header/ai-mentor/ai-mentor.component.html
+++ b/webapp/src/app/core/header/ai-mentor/ai-mentor.component.html
@@ -7,7 +7,7 @@
class="border-cyan-500 cursor-pointer text-cyan-500 hover:text-cyan-500 hover:bg-cyan-500/10 dark:hover:bg-cyan-500/20 gap-2"
variant="outline"
[size]="iconOnly() ? 'icon' : 'default'"
- [routerLink]="['/', 'chat']"
+ [routerLink]="['/', 'mentor']"
routerLinkActive="active"
>
diff --git a/webapp/src/app/core/security/mentor.guard.ts b/webapp/src/app/core/security/mentor.guard.ts
new file mode 100644
index 00000000..5d5fee08
--- /dev/null
+++ b/webapp/src/app/core/security/mentor.guard.ts
@@ -0,0 +1,26 @@
+import { inject, Injectable, Injector } from '@angular/core';
+import { toObservable } from '@angular/core/rxjs-interop';
+import { CanActivate, Router, UrlTree } from '@angular/router';
+import { SecurityStore } from '@app/core/security/security-store.service';
+import { filter, map, Observable } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class MentorGuard implements CanActivate {
+ injector = inject(Injector);
+ securityStore = inject(SecurityStore);
+ router = inject(Router);
+
+ canActivate(): Observable {
+ return toObservable(this.securityStore.loadedUser, { injector: this.injector }).pipe(
+ filter(Boolean),
+ map((user) => {
+ if (user && user.roles.includes('mentor_access')) {
+ return true;
+ }
+ return this.router.createUrlTree(['/']);
+ })
+ );
+ }
+}
diff --git a/webapp/src/app/chat/first-session-card/first-session-card.component.html b/webapp/src/app/mentor/first-session-card/first-session-card.component.html
similarity index 100%
rename from webapp/src/app/chat/first-session-card/first-session-card.component.html
rename to webapp/src/app/mentor/first-session-card/first-session-card.component.html
diff --git a/webapp/src/app/chat/first-session-card/first-session-card.component.ts b/webapp/src/app/mentor/first-session-card/first-session-card.component.ts
similarity index 100%
rename from webapp/src/app/chat/first-session-card/first-session-card.component.ts
rename to webapp/src/app/mentor/first-session-card/first-session-card.component.ts
diff --git a/webapp/src/app/chat/input/input.component.html b/webapp/src/app/mentor/input/input.component.html
similarity index 100%
rename from webapp/src/app/chat/input/input.component.html
rename to webapp/src/app/mentor/input/input.component.html
diff --git a/webapp/src/app/chat/input/input.component.ts b/webapp/src/app/mentor/input/input.component.ts
similarity index 100%
rename from webapp/src/app/chat/input/input.component.ts
rename to webapp/src/app/mentor/input/input.component.ts
diff --git a/webapp/src/app/chat/input/input.stories.ts b/webapp/src/app/mentor/input/input.stories.ts
similarity index 100%
rename from webapp/src/app/chat/input/input.stories.ts
rename to webapp/src/app/mentor/input/input.stories.ts
diff --git a/webapp/src/app/chat/chat/chat.component.html b/webapp/src/app/mentor/mentor.component.html
similarity index 100%
rename from webapp/src/app/chat/chat/chat.component.html
rename to webapp/src/app/mentor/mentor.component.html
diff --git a/webapp/src/app/chat/chat/chat.component.ts b/webapp/src/app/mentor/mentor.component.ts
similarity index 91%
rename from webapp/src/app/chat/chat/chat.component.ts
rename to webapp/src/app/mentor/mentor.component.ts
index 8ef3be95..6b752030 100644
--- a/webapp/src/app/chat/chat/chat.component.ts
+++ b/webapp/src/app/mentor/mentor.component.ts
@@ -2,23 +2,23 @@ import { Component, inject, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { lastValueFrom } from 'rxjs';
import { injectMutation, injectQuery } from '@tanstack/angular-query-experimental';
-import { SessionsCardComponent } from '../sessions-card/sessions-card.component';
-import { MessagesComponent } from '../messages/messages.component';
-import { InputComponent } from '../input/input.component';
+import { SessionsCardComponent } from './sessions-card/sessions-card.component';
+import { MessagesComponent } from './messages/messages.component';
+import { InputComponent } from './input/input.component';
import { SecurityStore } from '@app/core/security/security-store.service';
import { Message, Session } from '@app/core/modules/openapi';
import { MessageService, SessionService } from '@app/core/modules/openapi';
import { HlmButtonModule } from '@spartan-ng/ui-button-helm';
import { HlmSpinnerComponent } from '@spartan-ng/ui-spinner-helm';
-import { FirstSessionCardComponent } from '../first-session-card/first-session-card.component';
+import { FirstSessionCardComponent } from './first-session-card/first-session-card.component';
@Component({
- selector: 'app-chat',
- templateUrl: './chat.component.html',
+ selector: 'app-mentor',
+ templateUrl: './mentor.component.html',
standalone: true,
imports: [CommonModule, FirstSessionCardComponent, HlmSpinnerComponent, SessionsCardComponent, MessagesComponent, InputComponent, HlmButtonModule]
})
-export class ChatComponent {
+export class MentorComponent {
securityStore = inject(SecurityStore);
messageService = inject(MessageService);
sessionService = inject(SessionService);
diff --git a/webapp/src/app/chat/messages/messages.component.html b/webapp/src/app/mentor/messages/messages.component.html
similarity index 100%
rename from webapp/src/app/chat/messages/messages.component.html
rename to webapp/src/app/mentor/messages/messages.component.html
diff --git a/webapp/src/app/chat/messages/messages.component.ts b/webapp/src/app/mentor/messages/messages.component.ts
similarity index 100%
rename from webapp/src/app/chat/messages/messages.component.ts
rename to webapp/src/app/mentor/messages/messages.component.ts
diff --git a/webapp/src/app/chat/sessions-card/sessions-card.component.html b/webapp/src/app/mentor/sessions-card/sessions-card.component.html
similarity index 100%
rename from webapp/src/app/chat/sessions-card/sessions-card.component.html
rename to webapp/src/app/mentor/sessions-card/sessions-card.component.html
diff --git a/webapp/src/app/chat/sessions-card/sessions-card.component.ts b/webapp/src/app/mentor/sessions-card/sessions-card.component.ts
similarity index 100%
rename from webapp/src/app/chat/sessions-card/sessions-card.component.ts
rename to webapp/src/app/mentor/sessions-card/sessions-card.component.ts