From 5901e97ffdaca1c65ba653ca459a54bdee521427 Mon Sep 17 00:00:00 2001 From: chyoo Date: Thu, 13 Aug 2026 13:01:54 +0900 Subject: [PATCH] fix instructor student enrollment authorization --- src/auth/auth.service.ts | 2 +- src/instructor/instructor.service.ts | 30 ---------------------------- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index b11eab2..d7b1540 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -96,7 +96,7 @@ export class AuthService { accessToken: string, input: CreateManagedAuthUserInput, ) { - return this.request<{ user: AuthResponseUser }>('/auth/admin/users', { + return this.request<{ user: AuthResponseUser }>('/auth/instructor/students', { method: 'POST', body: input, accessToken, diff --git a/src/instructor/instructor.service.ts b/src/instructor/instructor.service.ts index 1ce71ac..1219412 100644 --- a/src/instructor/instructor.service.ts +++ b/src/instructor/instructor.service.ts @@ -998,8 +998,6 @@ export class InstructorService { }, ); - await this.grantLmsAppPermission(accessToken, createdAuthUser.user.id); - existingStudent = await this.prisma.user.upsert({ where: { email }, update: this.toUserSyncData(createdAuthUser.user), @@ -4111,40 +4109,12 @@ export class InstructorService { return files.filter((file) => file.path); } - private async grantLmsAppPermission(accessToken: string, authUserId: string) { - const launcherApiBaseUrl = this.launcherApiBaseUrl(); - const response = await fetch( - `${launcherApiBaseUrl}/apps/${encodeURIComponent('LMS')}/users/${encodeURIComponent(authUserId)}/permission`, - { - method: 'POST', - headers: { - authorization: `Bearer ${accessToken}`, - 'content-type': 'application/json', - }, - body: JSON.stringify({ - canView: true, - canLaunch: true, - }), - }, - ).catch(() => null); - - if (!response?.ok) { - const payload = await response?.json().catch((): null => null); - throw new BadGatewayException({ - message: 'Launcher app permission request failed', - statusCode: response?.status, - error: payload, - }); - } - } - private launcherApiBaseUrl() { return this.configService .get('LAUNCHER_API_BASE_URL', 'http://localhost:4200/api') .replace(/\/$/, ''); } - private toSummary(students: Array<{ progress: number; online: boolean; issues: number }>) { const total = students.length; const averageProgress = total