Slight renaming

This commit is contained in:
Amelia 2025-07-08 20:06:01 +02:00
parent 7cdf69533b
commit 5e367418d1
4 changed files with 11 additions and 12 deletions

View file

@ -1,6 +1,6 @@
import {DestroyRef, effect, inject, Injectable, signal} from '@angular/core'; import {computed, DestroyRef, inject, Injectable, signal} from '@angular/core';
import {OAuthErrorEvent, OAuthService} from "angular-oauth2-oidc"; import {OAuthErrorEvent, OAuthService} from "angular-oauth2-oidc";
import {BehaviorSubject, from, Observable} from "rxjs"; import {from} from "rxjs";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {environment} from "../../environments/environment"; import {environment} from "../../environments/environment";
import {OidcPublicConfig} from "../admin/_models/oidc-config"; import {OidcPublicConfig} from "../admin/_models/oidc-config";
@ -34,11 +34,11 @@ export class OidcService {
public readonly loaded = this._loaded.asReadonly(); public readonly loaded = this._loaded.asReadonly();
public readonly loaded$ = toObservable(this.loaded); public readonly loaded$ = toObservable(this.loaded);
/** public readonly inUse = computed(() => {
* OIDC discovery document has been loaded, login tried and OIDC has been set up const loaded = this.loaded();
*/ const settings = this.settings();
private readonly _ready = signal(false); return loaded && settings && settings.authority.trim() !== '';
public readonly ready = this._ready.asReadonly(); });
/** /**
* Public OIDC settings * Public OIDC settings
@ -96,7 +96,6 @@ export class OidcService {
from(this.oauth2.loadDiscoveryDocumentAndTryLogin()).subscribe({ from(this.oauth2.loadDiscoveryDocumentAndTryLogin()).subscribe({
next: _ => { next: _ => {
this._loaded.set(true); this._loaded.set(true);
this._ready.set(true);
}, },
error: error => { error: error => {
console.log(error); console.log(error);

View file

@ -102,9 +102,9 @@ export class AppComponent implements OnInit {
// Login automatically when a token is available // Login automatically when a token is available
effect(() => { effect(() => {
const ready = this.oidcService.ready(); const inUse = this.oidcService.inUse();
const user = this.accountService.currentUserSignal(); const user = this.accountService.currentUserSignal();
if (!ready || !this.oidcService.token || user) return; if (!inUse || !this.oidcService.token || user) return;
this.accountService.loginByToken(this.oidcService.token).subscribe({ this.accountService.loginByToken(this.oidcService.token).subscribe({
next: () => { next: () => {

View file

@ -17,7 +17,7 @@
<ngx-extended-pdf-viewer <ngx-extended-pdf-viewer
#pdfViewer #pdfViewer
[src]="readerService.downloadPdf(this.chapterId)" [src]="readerService.downloadPdf(this.chapterId)"
[authorization]="'Bearer ' + user.oidcToken ?? user.token" [authorization]="'Bearer ' + (user.oidcToken ?? user.token)"
height="100vh" height="100vh"
[(page)]="currentPage" [(page)]="currentPage"
[textLayer]="true" [textLayer]="true"

View file

@ -30,7 +30,7 @@
</form> </form>
} }
@if (oidcService.ready()) { @if (oidcService.inUse()) {
<button <button
class="btn btn-outline-primary mt-2 d-flex align-items-center gap-2" class="btn btn-outline-primary mt-2 d-flex align-items-center gap-2"
(click)="oidcService.login()"> (click)="oidcService.login()">