Browse Source

Add access token to preview URL.

pull/947/head
Sebastian 4 years ago
parent
commit
aed43dee91
  1. 9
      frontend/src/app/features/content/shared/preview-button.component.ts
  2. 8
      frontend/src/app/features/content/shared/references/reference-item.component.html

9
frontend/src/app/features/content/shared/preview-button.component.ts

@ -8,7 +8,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { ContentDto, interpolate, LocalStoreService, ModalModel, SchemaDto, Settings, StatefulComponent } from '@app/shared';
import { AuthService, ContentDto, interpolate, LocalStoreService, ModalModel, SchemaDto, Settings, StatefulComponent } from '@app/shared';
interface State {
// The name of the selected preview config.
@ -37,6 +37,7 @@ export class PreviewButtonComponent extends StatefulComponent<State> implements
public dropdown = new ModalModel();
constructor(changeDetector: ChangeDetectorRef,
private readonly authService: AuthService,
private readonly localStore: LocalStoreService,
) {
super(changeDetector, {
@ -74,7 +75,11 @@ export class PreviewButtonComponent extends StatefulComponent<State> implements
}
private navigateTo(name: string) {
const url = interpolate(this.schema.previewUrls[name], this.content, 'iv');
const vars = { ...this.content };
vars['accessToken'] = this.authService.user?.accessToken;
const url = interpolate(this.schema.previewUrls[name], vars, 'iv');
window.open(url, '_blank');
}

8
frontend/src/app/features/content/shared/references/reference-item.component.html

@ -49,10 +49,6 @@
<i class="icon-copy"></i>
</button>
<a class="btn btn-text-secondary" target="_blank" [routerLink]="['../..', content.schemaName, content.id]">
<i class="icon-pencil"></i>
</a>
<button type="button" class="btn btn-text-secondary" *ngIf="canRemove"
(sqxConfirmClick)="delete.emit()"
confirmTitle="i18n:contents.removeConfirmTitle"
@ -60,6 +56,10 @@
confirmRememberKey="removeReference">
<i class="icon-close"></i>
</button>
<a class="btn btn-text-secondary" target="_blank" [routerLink]="['../..', content.schemaName, content.id]">
<i class="icon-pencil"></i>
</a>
</div>
</div>
</td>

Loading…
Cancel
Save