mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-02 08:09:19 +08:00
Allow option to re-direct on logout action
- Add logout configuration - Change auth.service.ts to re-direct instead of posting depending on configuration
This commit is contained in:
parent
606d1540e3
commit
3cd6efcc3f
5 changed files with 34 additions and 5 deletions
|
@ -56,6 +56,7 @@ services:
|
|||
$subpanelTopActions: '%module.subpanel.top_actions%'
|
||||
$subpanelTopButtons: '%module.subpanel.top_buttons%'
|
||||
$ldapAutoCreateExtraFieldsMap: '%ldap.autocreate.extra_fields_map%'
|
||||
$logoutConfig: '%auth.logout%'
|
||||
_instanceof:
|
||||
App\Process\Service\ProcessHandlerInterface:
|
||||
tags: [ 'app.process.handler' ]
|
||||
|
@ -296,6 +297,8 @@ services:
|
|||
alias: App\SystemConfig\Service\SystemConfigProviderInterface
|
||||
public: true
|
||||
|
||||
Symfony\Component\Security\Http\Logout\LogoutUrlGenerator: '@security.logout_url_generator'
|
||||
|
||||
App\UserPreferences\Service\UserPreferencesProviderInterface: '@App\UserPreferences\LegacyHandler\UserPreferenceHandler'
|
||||
App\ViewDefinitions\Service\ViewDefinitionsProviderInterface: '@App\ViewDefinitions\LegacyHandler\ViewDefinitionsHandler'
|
||||
App\Engine\Service\FolderSync\FolderComparatorInterface: '@App\Engine\Service\FolderSync\FolderComparator'
|
||||
|
|
4
config/services/auth/logout.yaml
Normal file
4
config/services/auth/logout.yaml
Normal file
|
@ -0,0 +1,4 @@
|
|||
parameters:
|
||||
auth.logout:
|
||||
path: "%auth.logout.path%"
|
||||
redirect: "%auth.logout.redirect%"
|
|
@ -29,3 +29,4 @@ parameters:
|
|||
recordview_actions_limits: true
|
||||
ui: true
|
||||
extensions: true
|
||||
logout: true
|
||||
|
|
|
@ -29,7 +29,7 @@ import {Router} from '@angular/router';
|
|||
import {HttpClient, HttpErrorResponse, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {BehaviorSubject, Observable, Subscription, throwError} from 'rxjs';
|
||||
import {catchError, distinctUntilChanged, filter, finalize, take} from 'rxjs/operators';
|
||||
import {isEmptyString, User} from 'common';
|
||||
import {isEmptyString, isTrue, User} from 'common';
|
||||
import {MessageService} from '../message/message.service';
|
||||
import {StateManager} from '../../store/state-manager';
|
||||
import {LanguageStore} from '../../store/language/language.store';
|
||||
|
@ -148,21 +148,23 @@ export class AuthService {
|
|||
public logout(messageKey = 'LBL_LOGOUT_SUCCESS', redirect = true): void {
|
||||
this.appStateStore.updateLoading('logout', true, false);
|
||||
|
||||
let logoutUrl = 'logout';
|
||||
const logoutConfig = this.configs.getConfigValue('logout') ?? [];
|
||||
let logoutUrl = (logoutConfig?.path ?? 'logout') as string;
|
||||
const redirectLogout = isTrue(logoutConfig?.redirect ?? false);
|
||||
logoutUrl = this.baseRoute.calculateRoute(logoutUrl);
|
||||
const body = new HttpParams();
|
||||
|
||||
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
|
||||
|
||||
if (this.appStateStore.getActiveRequests() < 1) {
|
||||
this.callLogout(logoutUrl, body, headers, redirect, messageKey);
|
||||
this.callLogout(logoutUrl, body, headers, redirect, messageKey, redirectLogout);
|
||||
} else {
|
||||
this.appStateStore.activeRequests$.pipe(
|
||||
filter(value => value < 1),
|
||||
take(1)
|
||||
).subscribe(
|
||||
() => {
|
||||
this.callLogout(logoutUrl, body, headers, redirect, messageKey);
|
||||
this.callLogout(logoutUrl, body, headers, redirect, messageKey, redirectLogout);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -175,10 +177,23 @@ export class AuthService {
|
|||
* @param headers
|
||||
* @param redirect
|
||||
* @param messageKey
|
||||
* @param redirectLogout
|
||||
* @protected
|
||||
*/
|
||||
protected callLogout(logoutUrl: string, body: HttpParams, headers: HttpHeaders, redirect: boolean, messageKey: string) {
|
||||
protected callLogout(
|
||||
logoutUrl: string,
|
||||
body: HttpParams,
|
||||
headers: HttpHeaders,
|
||||
redirect: boolean,
|
||||
messageKey: string,
|
||||
redirectLogout: boolean
|
||||
) {
|
||||
this.resetState();
|
||||
|
||||
if (redirectLogout) {
|
||||
window.location.href = logoutUrl;
|
||||
return;
|
||||
}
|
||||
this.http.post(logoutUrl, body.toString(), {headers, responseType: 'text'})
|
||||
.pipe(
|
||||
take(1),
|
||||
|
|
|
@ -100,6 +100,7 @@ class SystemConfigHandler extends LegacyHandler implements SystemConfigProviderI
|
|||
* @param array $listViewLineActionsLimits
|
||||
* @param array $uiConfigs
|
||||
* @param array $extensions
|
||||
* @param array $logoutConfig
|
||||
* @param SessionInterface $session
|
||||
* @param NavigationProviderInterface $navigation
|
||||
*/
|
||||
|
@ -126,6 +127,7 @@ class SystemConfigHandler extends LegacyHandler implements SystemConfigProviderI
|
|||
array $listViewLineActionsLimits,
|
||||
array $uiConfigs,
|
||||
array $extensions,
|
||||
array $logoutConfig,
|
||||
SessionInterface $session,
|
||||
NavigationProviderInterface $navigation
|
||||
) {
|
||||
|
@ -152,6 +154,10 @@ class SystemConfigHandler extends LegacyHandler implements SystemConfigProviderI
|
|||
$this->injectedSystemConfigs['listview_line_actions_limits'] = $listViewLineActionsLimits;
|
||||
$this->injectedSystemConfigs['ui'] = $uiConfigs;
|
||||
$this->injectedSystemConfigs['extensions'] = $extensions;
|
||||
|
||||
$logoutConfig = $logoutConfig ?? [];
|
||||
$this->injectedSystemConfigs['logout'] = $logoutConfig;
|
||||
|
||||
$this->mappers = $mappers;
|
||||
$this->systemConfigKeyMap = $systemConfigKeyMap;
|
||||
$this->currencyHandler = $currencyHandler;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue