From 6ef67fbc640071954addc95f65739ae81a7b2fce Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Mon, 16 May 2022 22:55:50 +0200 Subject: [PATCH] Fix #82 - Add a proxy logout URL and skip auto lock when it is not set --- app/Http/Controllers/SinglePageController.php | 6 +++++- config/2fauth.php | 1 + resources/js/app.js | 1 + resources/js/components/Footer.vue | 5 ++++- resources/js/mixins.js | 15 +++++++++++---- resources/views/landing.blade.php | 1 + 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/SinglePageController.php b/app/Http/Controllers/SinglePageController.php index 00eb686f..26a3c78b 100644 --- a/app/Http/Controllers/SinglePageController.php +++ b/app/Http/Controllers/SinglePageController.php @@ -32,9 +32,13 @@ class SinglePageController extends Controller { return view('landing')->with([ 'appSettings' => $this->settingService->all()->toJson(), + 'appConfig' => collect([ + 'proxyAuth' => config("auth.defaults.guard") === 'reverse-proxy-guard' ? true : false, + 'proxyLogoutUrl' => config("2fauth.config.proxyLogoutUrl") ? config("2fauth.config.proxyLogoutUrl") : false, + ])->toJson(), 'lang' => App::currentLocale(), 'isDemoApp' => config("2fauth.config.isDemoApp") ? 'true' : 'false', - 'locales' => collect(config("2fauth.locales"))->toJson(), + 'locales' => collect(config("2fauth.locales"))->toJson() ]); } } diff --git a/config/2fauth.php b/config/2fauth.php index cb8efc66..4314d3ee 100644 --- a/config/2fauth.php +++ b/config/2fauth.php @@ -21,6 +21,7 @@ return [ 'config' => [ 'isDemoApp' => env('IS_DEMO_APP', false), 'trustedProxies' => env('TRUSTED_PROXIES', null), + 'proxyLogoutUrl' => env('PROXY_LOGOUT_URL', null), ], /* diff --git a/resources/js/app.js b/resources/js/app.js index fc807571..ca5fb4e8 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -16,6 +16,7 @@ const app = new Vue({ el: '#app', data: { appSettings: window.appSettings, + appConfig: window.appConfig, isDemoApp: window.isDemoApp }, i18n, diff --git a/resources/js/components/Footer.vue b/resources/js/components/Footer.vue index 5c91c14b..efb43cf7 100644 --- a/resources/js/components/Footer.vue +++ b/resources/js/components/Footer.vue @@ -11,7 +11,10 @@ 2FAuth - v{{ appVersion }}
- {{ $t('settings.settings') }} - {{ $t('auth.sign_out') }} + {{ $t('settings.settings') }} + + - {{ $t('auth.sign_out') }} +
diff --git a/resources/js/mixins.js b/resources/js/mixins.js index 159695c4..524cecf2 100644 --- a/resources/js/mixins.js +++ b/resources/js/mixins.js @@ -11,10 +11,17 @@ Vue.mixin({ methods: { async appLogout(evt) { - - await this.axios.get('/user/logout') - this.$storage.clear() - location.reload() + if (this.$root.appConfig.proxyAuth) { + if (this.$root.appConfig.proxyLogoutUrl) { + location.assign(this.$root.appConfig.proxyLogoutUrl) + } + else return false + } + else { + await this.axios.get('/user/logout') + this.$storage.clear() + location.reload() + } }, exitSettings: function(event) { diff --git a/resources/views/landing.blade.php b/resources/views/landing.blade.php index 89278fb8..df801924 100644 --- a/resources/views/landing.blade.php +++ b/resources/views/landing.blade.php @@ -24,6 +24,7 @@