fix instructor student enrollment authorization

This commit is contained in:
2026-08-13 13:01:54 +09:00
parent 5c03032921
commit 5901e97ffd
2 changed files with 1 additions and 31 deletions
-30
View File
@@ -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<string>('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