mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-10-20 16:32:16 +00:00
fix: don't use token param for assessments in prod
This commit is contained in:
@@ -23,6 +23,7 @@ import {DataProvider, DataScope} from '../../data/data.provider';
|
|||||||
import {DataRoutingService} from '../../data/data-routing.service';
|
import {DataRoutingService} from '../../data/data-routing.service';
|
||||||
import {groupBy, mapValues} from '@openstapps/collection-utils';
|
import {groupBy, mapValues} from '@openstapps/collection-utils';
|
||||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||||
|
import {environment} from '../../../../environments/environment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-assessments-page',
|
selector: 'app-assessments-page',
|
||||||
@@ -62,6 +63,26 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
destroy$ = inject(DestroyRef);
|
destroy$ = inject(DestroyRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ?token=... (e.g. ?token=mock) is a development aid only.
|
||||||
|
* In production, no token is read from or passed on in URLs.
|
||||||
|
*/
|
||||||
|
private readonly urlTokenAllowed = !environment.production;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token from the URL (?token=...), development only.
|
||||||
|
* Always undefined in production, so no token is read from or passed on in URLs.
|
||||||
|
*/
|
||||||
|
get urlToken(): string | undefined {
|
||||||
|
if (!this.urlTokenAllowed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = this.activatedRoute.snapshot.queryParamMap.get('token');
|
||||||
|
|
||||||
|
return token === null ? undefined : token;
|
||||||
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.segmentView.value = this.sharedAxisChoreographer.currentValue;
|
this.segmentView.value = this.sharedAxisChoreographer.currentValue;
|
||||||
}
|
}
|
||||||
@@ -73,7 +94,7 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
|||||||
.subscribe(thing => {
|
.subscribe(thing => {
|
||||||
void this.router.navigate(['assessments', 'detail', thing.uid], {
|
void this.router.navigate(['assessments', 'detail', thing.uid], {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
token: this.activatedRoute.snapshot.queryParamMap.get('token'),
|
token: this.urlToken,
|
||||||
},
|
},
|
||||||
state: {item: thing},
|
state: {item: thing},
|
||||||
});
|
});
|
||||||
@@ -82,7 +103,7 @@ export class AssessmentsPageComponent implements OnInit, AfterViewInit {
|
|||||||
this.activatedRoute.queryParams.subscribe(parameters => {
|
this.activatedRoute.queryParams.subscribe(parameters => {
|
||||||
try {
|
try {
|
||||||
this.assessments = this.assessmentsProvider
|
this.assessments = this.assessmentsProvider
|
||||||
.getAssessments(parameters.token)
|
.getAssessments(this.urlTokenAllowed ? parameters.token : undefined)
|
||||||
.then(assessments => groupBy(assessments, it => it.courseOfStudy?.uid ?? 'unknown'))
|
.then(assessments => groupBy(assessments, it => it.courseOfStudy?.uid ?? 'unknown'))
|
||||||
.then(it => {
|
.then(it => {
|
||||||
this.assessmentKeys = Object.keys(it);
|
this.assessmentKeys = Object.keys(it);
|
||||||
|
|||||||
Reference in New Issue
Block a user