mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: add auth support (default and paia)
This commit is contained in:
committed by
Jovan Krunić
parent
046a95ba1d
commit
b5f239ea4e
@@ -16,10 +16,14 @@ import {Component, NgZone} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {App, URLOpenListenerEvent} from '@capacitor/app';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {Platform, ToastController} from '@ionic/angular';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {ConfigProvider} from './modules/config/config.provider';
|
||||
import {SettingsProvider} from './modules/settings/settings.provider';
|
||||
import {PAIAAuthService} from './modules/auth/paia/paia-auth.service';
|
||||
import {DefaultAuthService} from './modules/auth/default-auth.service';
|
||||
import {environment} from '../environments/environment';
|
||||
import {AuthHelperService} from './modules/auth/auth-helper.service';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -51,6 +55,10 @@ export class AppComponent {
|
||||
* @param logger An angular logger
|
||||
* @param router The angular router
|
||||
* @param zone The angular zone
|
||||
* @param defaultAuth Auth Service
|
||||
* @param paiaAuth Auth Service
|
||||
* @param authHelperService Helper service for OAuth providers
|
||||
* @param toastController Toast controller
|
||||
*/
|
||||
constructor(
|
||||
private readonly platform: Platform,
|
||||
@@ -59,6 +67,10 @@ export class AppComponent {
|
||||
private readonly logger: NGXLogger,
|
||||
private readonly router: Router,
|
||||
private readonly zone: NgZone,
|
||||
private readonly defaultAuth: DefaultAuthService,
|
||||
private readonly paiaAuth: PAIAAuthService,
|
||||
private readonly authHelperService: AuthHelperService,
|
||||
private readonly toastController: ToastController,
|
||||
) {
|
||||
void this.initializeApp();
|
||||
}
|
||||
@@ -69,7 +81,7 @@ export class AppComponent {
|
||||
async initializeApp() {
|
||||
App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => {
|
||||
this.zone.run(() => {
|
||||
const slug = event.url.split('.de').pop();
|
||||
const slug = event.url.split(environment.appDomain).pop();
|
||||
if (slug) {
|
||||
this.router.navigateByUrl(slug);
|
||||
}
|
||||
@@ -78,6 +90,9 @@ export class AppComponent {
|
||||
});
|
||||
});
|
||||
this.platform.ready().then(async () => {
|
||||
await this.authInit();
|
||||
await this.defaultAuth.init();
|
||||
await this.paiaAuth.init();
|
||||
await SplashScreen.hide();
|
||||
|
||||
// initialise the configProvider
|
||||
@@ -102,4 +117,28 @@ export class AppComponent {
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
private async authInit() {
|
||||
await this.defaultAuth.init();
|
||||
await this.paiaAuth.init();
|
||||
this.defaultAuth.events$.subscribe(action =>
|
||||
this.showMessage(
|
||||
this.authHelperService.getAuthMessage('default', action),
|
||||
),
|
||||
);
|
||||
this.paiaAuth.events$.subscribe(action =>
|
||||
this.showMessage(this.authHelperService.getAuthMessage('paia', action)),
|
||||
);
|
||||
}
|
||||
|
||||
private async showMessage(message?: string) {
|
||||
if (typeof message === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const toast = await this.toastController.create({
|
||||
message: message,
|
||||
duration: 2000,
|
||||
});
|
||||
await toast.present();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user