mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-20 05:23:40 +02:00
🐛 fix(matrix-web): handle Matrix SSO loginToken callback
Add loginWithLoginToken function to exchange Matrix SSO loginToken for credentials. The app layout now detects the loginToken URL parameter and completes the SSO flow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9e9db590dc
commit
dc0d425f61
53 changed files with 1550 additions and 230 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { MatrixService } from './matrix.service';
|
||||
import { SkilltreeModule } from '../skilltree/skilltree.module';
|
||||
import { SessionModule, TranscriptionModule } from '@manacore/bot-services';
|
||||
import { SessionModule, TranscriptionModule, CreditModule } from '@manacore/bot-services';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
|
@ -10,6 +10,7 @@ import { SessionModule, TranscriptionModule } from '@manacore/bot-services';
|
|||
TranscriptionModule.register({
|
||||
sttUrl: process.env.STT_URL || 'http://localhost:3020',
|
||||
}),
|
||||
CreditModule.forRoot(),
|
||||
],
|
||||
providers: [MatrixService],
|
||||
exports: [MatrixService],
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
COMMON_KEYWORDS,
|
||||
} from '@manacore/matrix-bot-common';
|
||||
import { SkilltreeService, Skill, SkillBranch } from '../skilltree/skilltree.service';
|
||||
import { SessionService, TranscriptionService } from '@manacore/bot-services';
|
||||
import { SessionService, TranscriptionService, CreditService } from '@manacore/bot-services';
|
||||
import { HELP_MESSAGE } from '../config/configuration';
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -55,7 +55,8 @@ export class MatrixService extends BaseMatrixService {
|
|||
configService: ConfigService,
|
||||
private skilltreeService: SkilltreeService,
|
||||
private sessionService: SessionService,
|
||||
private readonly transcriptionService: TranscriptionService
|
||||
private readonly transcriptionService: TranscriptionService,
|
||||
private creditService: CreditService
|
||||
) {
|
||||
super(configService);
|
||||
}
|
||||
|
|
@ -207,7 +208,13 @@ export class MatrixService extends BaseMatrixService {
|
|||
const result = await this.sessionService.login(sender, email, password);
|
||||
|
||||
if (result.success) {
|
||||
await this.sendMessage(roomId, `<p>Erfolgreich angemeldet als <strong>${email}</strong></p>`);
|
||||
const token = this.sessionService.getToken(sender);
|
||||
if (token) {
|
||||
const balance = await this.creditService.getBalance(token);
|
||||
await this.sendMessage(roomId, `<p>✅ Erfolgreich angemeldet als <strong>${email}</strong><br/>⚡ Credits: ${balance.balance.toFixed(2)}</p>`);
|
||||
} else {
|
||||
await this.sendMessage(roomId, `<p>✅ Erfolgreich angemeldet als <strong>${email}</strong></p>`);
|
||||
}
|
||||
} else {
|
||||
await this.sendMessage(roomId, `<p>Login fehlgeschlagen: ${result.error}</p>`);
|
||||
}
|
||||
|
|
@ -217,16 +224,23 @@ export class MatrixService extends BaseMatrixService {
|
|||
const backendOk = await this.skilltreeService.checkHealth();
|
||||
const loggedIn = this.sessionService.isLoggedIn(sender);
|
||||
const sessions = this.sessionService.getSessionCount();
|
||||
const session = this.sessionService.getSession(sender);
|
||||
const token = this.sessionService.getToken(sender);
|
||||
|
||||
await this.sendMessage(
|
||||
roomId,
|
||||
`<h3>Skilltree Bot Status</h3>
|
||||
<ul>
|
||||
<li>Backend: ${backendOk ? 'Online' : 'Offline'}</li>
|
||||
<li>Angemeldet: ${loggedIn ? 'Ja' : 'Nein'}</li>
|
||||
<li>Aktive Sessions: ${sessions}</li>
|
||||
</ul>`
|
||||
);
|
||||
let statusHtml = '<h3>Skilltree Bot Status</h3><ul>';
|
||||
statusHtml += `<li>Backend: ${backendOk ? 'Online' : 'Offline'}</li>`;
|
||||
statusHtml += `<li>Angemeldet: ${loggedIn ? 'Ja' : 'Nein'}</li>`;
|
||||
|
||||
if (loggedIn && session && token) {
|
||||
const balance = await this.creditService.getBalance(token);
|
||||
statusHtml += `<li>👤 Angemeldet als: ${session.email}</li>`;
|
||||
statusHtml += `<li>⚡ Credits: ${balance.balance.toFixed(2)}</li>`;
|
||||
}
|
||||
|
||||
statusHtml += `<li>Aktive Sessions: ${sessions}</li>`;
|
||||
statusHtml += '</ul>';
|
||||
|
||||
await this.sendMessage(roomId, statusHtml);
|
||||
}
|
||||
|
||||
// Skill handlers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue