From ef092a8bff00935bcfc6905d81078a87e2abd970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thea=20Sch=C3=B6bl?= Date: Tue, 17 Oct 2023 18:00:55 +0200 Subject: [PATCH] fix: library login fails --- .../page/auth-callback-page.component.html | 2 +- .../page/auth-callback-page.component.ts | 16 +++++---- .../app/modules/auth/auth-routing.module.ts | 6 ++-- .../app/src/app/modules/auth/auth.module.ts | 3 +- .../page/paiaauth-callback-page.component.ts | 33 ------------------- frontend/app/src/assets/i18n/de.json | 3 +- frontend/app/src/assets/i18n/en.json | 3 +- 7 files changed, 17 insertions(+), 49 deletions(-) delete mode 100644 frontend/app/src/app/modules/auth/paia/auth-callback/page/paiaauth-callback-page.component.ts diff --git a/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.html b/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.html index e55be4e4..b32f203f 100644 --- a/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.html +++ b/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.html @@ -15,6 +15,6 @@

- {{ 'auth.messages' + '.' + PROVIDER_TYPE + '.' + 'authorizing' | translate }} + {{ 'auth.messages.authorizing' | translate }}

diff --git a/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.ts b/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.ts index 9b815412..c21ab68f 100644 --- a/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.ts +++ b/frontend/app/src/app/modules/auth/auth-callback/page/auth-callback-page.component.ts @@ -16,25 +16,27 @@ import {Component} from '@angular/core'; import {NavController} from '@ionic/angular'; import {Router} from '@angular/router'; import {AuthActions, IAuthAction} from 'ionic-appauth'; -import {SCAuthorizationProviderType} from '@openstapps/core'; import {AuthHelperService} from '../../auth-helper.service'; import {takeUntilDestroyed} from '@angular/core/rxjs-interop'; import {Observable} from 'rxjs'; import {IPAIAAuthAction} from '../../paia/paia-auth-action'; +import {DefaultAuthService} from '../../default-auth.service'; @Component({ templateUrl: 'auth-callback-page.component.html', styleUrls: ['auth-callback-page.component.scss'], }) export class AuthCallbackPageComponent { - PROVIDER_TYPE: SCAuthorizationProviderType = 'default'; - - constructor(private navCtrl: NavController, private router: Router, private authHelper: AuthHelperService) { - const provider = this.authHelper.getProvider(this.PROVIDER_TYPE); - const events: Observable = provider.events$; + constructor( + private navCtrl: NavController, + private router: Router, + private authHelper: AuthHelperService, + private auth: DefaultAuthService, + ) { + const events: Observable = this.auth.events$; events.pipe(takeUntilDestroyed()).subscribe((action: IAuthAction) => this.postCallback(action)); - provider.authorizationCallback(window.location.origin + this.router.url); + this.auth.authorizationCallback(window.location.origin + this.router.url); } async postCallback(action: IAuthAction) { diff --git a/frontend/app/src/app/modules/auth/auth-routing.module.ts b/frontend/app/src/app/modules/auth/auth-routing.module.ts index d8c5f9e5..a7a0c265 100644 --- a/frontend/app/src/app/modules/auth/auth-routing.module.ts +++ b/frontend/app/src/app/modules/auth/auth-routing.module.ts @@ -17,7 +17,8 @@ import {RouterModule, Routes} from '@angular/router'; import {NgModule} from '@angular/core'; import {authPaths} from './auth-paths'; import {AuthCallbackPageComponent} from './auth-callback/page/auth-callback-page.component'; -import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/paiaauth-callback-page.component'; +import {DefaultAuthService} from './default-auth.service'; +import {PAIAAuthService} from './paia/paia-auth.service'; const authRoutes: Routes = [ { @@ -26,7 +27,8 @@ const authRoutes: Routes = [ }, { path: authPaths.paia.redirect_path, - component: PAIAAuthCallbackPageComponent, + component: AuthCallbackPageComponent, + providers: [{provide: DefaultAuthService, useExisting: PAIAAuthService}], }, ]; diff --git a/frontend/app/src/app/modules/auth/auth.module.ts b/frontend/app/src/app/modules/auth/auth.module.ts index 17708add..690a4c2c 100644 --- a/frontend/app/src/app/modules/auth/auth.module.ts +++ b/frontend/app/src/app/modules/auth/auth.module.ts @@ -10,12 +10,11 @@ import {HttpClient} from '@angular/common/http'; import {AuthRoutingModule} from './auth-routing.module'; import {TranslateModule} from '@ngx-translate/core'; import {AuthCallbackPageComponent} from './auth-callback/page/auth-callback-page.component'; -import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/paiaauth-callback-page.component'; import {DefaultAuthService} from './default-auth.service'; import {PAIAAuthService} from './paia/paia-auth.service'; @NgModule({ - declarations: [AuthCallbackPageComponent, PAIAAuthCallbackPageComponent], + declarations: [AuthCallbackPageComponent], imports: [CommonModule, AuthRoutingModule, TranslateModule], providers: [ { diff --git a/frontend/app/src/app/modules/auth/paia/auth-callback/page/paiaauth-callback-page.component.ts b/frontend/app/src/app/modules/auth/paia/auth-callback/page/paiaauth-callback-page.component.ts deleted file mode 100644 index fd390eb4..00000000 --- a/frontend/app/src/app/modules/auth/paia/auth-callback/page/paiaauth-callback-page.component.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 StApps - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -import {Component} from '@angular/core'; -import {AuthCallbackPageComponent} from '../../../auth-callback/page/auth-callback-page.component'; -import {SCAuthorizationProviderType} from '@openstapps/core'; -import {NavController} from '@ionic/angular'; -import {Router} from '@angular/router'; -import {AuthHelperService} from '../../../auth-helper.service'; - -@Component({ - templateUrl: '../../../auth-callback/page/auth-callback-page.component.html', - styleUrls: ['../../../auth-callback/page/auth-callback-page.component.scss'], -}) -export class PAIAAuthCallbackPageComponent extends AuthCallbackPageComponent { - PROVIDER_TYPE = 'paia' as SCAuthorizationProviderType; - - constructor(navCtrl: NavController, router: Router, authHelper: AuthHelperService) { - super(navCtrl, router, authHelper); - } -} diff --git a/frontend/app/src/assets/i18n/de.json b/frontend/app/src/assets/i18n/de.json index 90fc1975..c7bc5cd2 100644 --- a/frontend/app/src/assets/i18n/de.json +++ b/frontend/app/src/assets/i18n/de.json @@ -47,8 +47,8 @@ "auth": { "messages": { "encourage_login": "Für mehr einloggen", + "authorizing": "Autorisierung läuft...", "default": { - "authorizing": "Autorisierung läuft...", "logged_in_success": "Erfolgreich eingeloggt.", "logged_out_success": "Erfolgreich ausgeloggt.", "log_out_alert": { @@ -57,7 +57,6 @@ } }, "paia": { - "authorizing": "Autorisierung (Bibliothek) läuft...", "logged_in_success": "Erfolgreich ins Bibliothekskonto eingeloggt.", "logged_out_success": "Erfolgreich aus dem Bibliothekskonto ausgeloggt.", "log_out_alert": { diff --git a/frontend/app/src/assets/i18n/en.json b/frontend/app/src/assets/i18n/en.json index e3651849..fe14dddc 100644 --- a/frontend/app/src/assets/i18n/en.json +++ b/frontend/app/src/assets/i18n/en.json @@ -47,8 +47,8 @@ "auth": { "messages": { "encourage_login": "Log in for more", + "authorizing": "Authorizing...", "default": { - "authorizing": "Authorizing...", "logged_in_success": "Successfully logged in.", "logged_out_success": "Successfully logged out.", "log_out_alert": { @@ -57,7 +57,6 @@ } }, "paia": { - "authorizing": "Authorizing (library)...", "logged_in_success": "Successfully logged in to library.", "logged_out_success": "Successfully logged out from library.", "log_out_alert": {