From e3fce9191a4dabee6b5392dbd4de640c80aff5d9 Mon Sep 17 00:00:00 2001 From: Neal Shah <30693865+ProgrammerIn-wonderland@users.noreply.github.com> Date: Mon, 6 Jul 2026 11:23:27 -0400 Subject: [PATCH] emit puter.app.authenticated event (#3337) --- .../controllers/auth/AuthController.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/backend/controllers/auth/AuthController.ts b/src/backend/controllers/auth/AuthController.ts index ee71d0117..70d649660 100644 --- a/src/backend/controllers/auth/AuthController.ts +++ b/src/backend/controllers/auth/AuthController.ts @@ -23,8 +23,8 @@ import crypto from 'node:crypto'; import { v4 as uuidv4 } from 'uuid'; import validator from 'validator'; import { Controller, Get, Post } from '../../core/http/decorators.js'; -import { HttpError } from '../../core/http/HttpError.js'; import type { HttpErrorOptions } from '../../core/http/HttpError.js'; +import { HttpError } from '../../core/http/HttpError.js'; import { antiCsrf } from '../../core/http/middleware/antiCsrf.js'; import { generateCaptcha } from '../../core/http/middleware/captcha.js'; import { checkRateLimit } from '../../core/http/middleware/rateLimit.js'; @@ -2796,6 +2796,33 @@ export class AuthController extends PuterController { await Promise.all([userPermGrantPromise, missingFSPathPromise]); + try { + const a = app as { + id?: number; + uid?: string; + index_url?: string | null; + owner_user_id?: number | null; + name?: string | null; + }; + this.clients.event?.emit( + 'puter.app.authenticated' as never, + { + app_uid, + app: { + id: a.id, + uid: a.uid, + index_url: a.index_url ?? null, + owner_user_id: a.owner_user_id ?? null, + name: a.name ?? null, + }, + user_id: req.actor!.user?.id ?? null, + } as never, + {}, + ); + } catch { + // Fine if failed + } + res.json({ token, app_uid }); }