fix instructor student enrollment authorization
This commit is contained in:
@@ -96,7 +96,7 @@ export class AuthService {
|
|||||||
accessToken: string,
|
accessToken: string,
|
||||||
input: CreateManagedAuthUserInput,
|
input: CreateManagedAuthUserInput,
|
||||||
) {
|
) {
|
||||||
return this.request<{ user: AuthResponseUser }>('/auth/admin/users', {
|
return this.request<{ user: AuthResponseUser }>('/auth/instructor/students', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: input,
|
body: input,
|
||||||
accessToken,
|
accessToken,
|
||||||
|
|||||||
@@ -998,8 +998,6 @@ export class InstructorService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.grantLmsAppPermission(accessToken, createdAuthUser.user.id);
|
|
||||||
|
|
||||||
existingStudent = await this.prisma.user.upsert({
|
existingStudent = await this.prisma.user.upsert({
|
||||||
where: { email },
|
where: { email },
|
||||||
update: this.toUserSyncData(createdAuthUser.user),
|
update: this.toUserSyncData(createdAuthUser.user),
|
||||||
@@ -4111,40 +4109,12 @@ export class InstructorService {
|
|||||||
return files.filter((file) => file.path);
|
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() {
|
private launcherApiBaseUrl() {
|
||||||
return this.configService
|
return this.configService
|
||||||
.get<string>('LAUNCHER_API_BASE_URL', 'http://localhost:4200/api')
|
.get<string>('LAUNCHER_API_BASE_URL', 'http://localhost:4200/api')
|
||||||
.replace(/\/$/, '');
|
.replace(/\/$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private toSummary(students: Array<{ progress: number; online: boolean; issues: number }>) {
|
private toSummary(students: Array<{ progress: number; online: boolean; issues: number }>) {
|
||||||
const total = students.length;
|
const total = students.length;
|
||||||
const averageProgress = total
|
const averageProgress = total
|
||||||
|
|||||||
Reference in New Issue
Block a user