mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-07 05:52:57 +00:00
committed by
Rainer Killinger
parent
cc939f3887
commit
7f6de94ab5
@@ -29,6 +29,7 @@ import {StorageProvider} from '../storage/storage.provider';
|
|||||||
import {DefaultAuthService} from './default-auth.service';
|
import {DefaultAuthService} from './default-auth.service';
|
||||||
import {PAIAAuthService} from './paia/paia-auth.service';
|
import {PAIAAuthService} from './paia/paia-auth.service';
|
||||||
import {SimpleBrowser} from '../../util/browser.factory';
|
import {SimpleBrowser} from '../../util/browser.factory';
|
||||||
|
import {AlertController} from '@ionic/angular';
|
||||||
|
|
||||||
const AUTH_ORIGIN_PATH = 'stapps.auth.origin_path';
|
const AUTH_ORIGIN_PATH = 'stapps.auth.origin_path';
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ export class AuthHelperService {
|
|||||||
private defaultAuth: DefaultAuthService,
|
private defaultAuth: DefaultAuthService,
|
||||||
private paiaAuth: PAIAAuthService,
|
private paiaAuth: PAIAAuthService,
|
||||||
private browser: SimpleBrowser,
|
private browser: SimpleBrowser,
|
||||||
|
private alertController: AlertController,
|
||||||
) {
|
) {
|
||||||
this.userConfigurationMap = (
|
this.userConfigurationMap = (
|
||||||
this.configProvider.getAnyValue('auth') as {
|
this.configProvider.getAnyValue('auth') as {
|
||||||
@@ -118,11 +120,33 @@ export class AuthHelperService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends browser session by opening endSessionEndpoint URL of the provider
|
* Ends browser session by opening endSessionEndpoint URL of the provider
|
||||||
|
*
|
||||||
|
* @param providerType Type of the provider (e.g. 'default' or 'paia')
|
||||||
*/
|
*/
|
||||||
async endBrowserSession(providerType: SCAuthorizationProviderType) {
|
async endBrowserSession(providerType: SCAuthorizationProviderType) {
|
||||||
const endSessionEndpoint = (await this.getProvider(providerType).configuration).endSessionEndpoint ?? '';
|
const endSessionEndpoint = (await this.getProvider(providerType).configuration).endSessionEndpoint;
|
||||||
if (endSessionEndpoint.length > 0) {
|
|
||||||
this.browser.open(new URL(endSessionEndpoint).href);
|
if (endSessionEndpoint) {
|
||||||
|
const alert: HTMLIonAlertElement = await this.alertController.create({
|
||||||
|
header: this.translateService.instant(`auth.messages.${providerType}.log_out_alert.header`),
|
||||||
|
message: this.translateService.instant(`auth.messages.${providerType}.log_out_alert.message`),
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: this.translateService.instant('no'),
|
||||||
|
cssClass: 'default',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: this.translateService.instant('yes'),
|
||||||
|
role: 'confirm',
|
||||||
|
cssClass: 'preferred',
|
||||||
|
handler: () => {
|
||||||
|
this.browser.open(new URL(endSessionEndpoint).href);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await alert.present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import {AuthHelperService} from '../../auth/auth-helper.service';
|
|||||||
import {Observable, Subscription} from 'rxjs';
|
import {Observable, Subscription} from 'rxjs';
|
||||||
import {SCAuthorizationProviderType} from '@openstapps/core';
|
import {SCAuthorizationProviderType} from '@openstapps/core';
|
||||||
import Swiper from 'swiper';
|
import Swiper from 'swiper';
|
||||||
import {AlertController} from '@ionic/angular';
|
|
||||||
import {TranslateService} from '@ngx-translate/core';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'stapps-profile-page-section',
|
selector: 'stapps-profile-page-section',
|
||||||
@@ -55,11 +53,7 @@ export class ProfilePageSectionComponent implements OnInit, OnDestroy {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(
|
constructor(private authHelper: AuthHelperService) {}
|
||||||
private authHelper: AuthHelperService,
|
|
||||||
private alertController: AlertController,
|
|
||||||
private translateService: TranslateService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.item.authProvider) {
|
if (this.item.authProvider) {
|
||||||
@@ -100,27 +94,7 @@ export class ProfilePageSectionComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
async signOut(providerType: SCAuthorizationProviderType) {
|
async signOut(providerType: SCAuthorizationProviderType) {
|
||||||
await this.authHelper.getProvider(providerType).signOut();
|
await this.authHelper.getProvider(providerType).signOut();
|
||||||
|
await this.authHelper.endBrowserSession(providerType);
|
||||||
const alert: HTMLIonAlertElement = await this.alertController.create({
|
|
||||||
header: this.translateService.instant(`auth.messages.${providerType}.log_out_alert.header`),
|
|
||||||
message: this.translateService.instant(`auth.messages.${providerType}.log_out_alert.message`),
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
text: this.translateService.instant('no'),
|
|
||||||
cssClass: 'default',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: this.translateService.instant('yes'),
|
|
||||||
role: 'confirm',
|
|
||||||
cssClass: 'preferred',
|
|
||||||
handler: () => {
|
|
||||||
this.authHelper.endBrowserSession(providerType);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
await alert.present();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user