1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

[fix] redirect logout (#636)

* [fix] Logout on sso if needed

* Auto-update README

* [fix] Bad path in patch

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com>
Co-authored-by: ericgaspar <junk.eg@free.fr>
This commit is contained in:
ljf (zamentur) 2024-04-24 22:31:50 +02:00 committed by GitHub
parent b05bcf5b4f
commit 830f904804
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 13 deletions

View file

@ -155,12 +155,13 @@ fi
#=================================================
# Add dynamic logout URL to the config
url_base64="$(echo -n "https://$domain$path" | base64)"
exec_occ config:system:get logout_url >/dev/null 2>&1 \
|| echo "
//-YunoHost-
// set logout_url according to main domain
\$main_domain = exec('cat /etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout&r=${url_base64}';
//-YunoHost-
" >> "$install_dir/config/config.php"

View file

@ -260,14 +260,19 @@ then
#=================================================
# Add dynamic logout URL to the config
exec_occ config:system:get logout_url >/dev/null 2>&1 \
|| echo "
url_base64="$(echo -n "https://$domain$path" | base64)"
old_logout_url="https://$(cat /etc/yunohost/current_host)/yunohost/sso/?action=logout"
current_logout_url="$(exec_occ config:system:get logout_url 2> /dev/null)"
if [[ "$current_logout_url" == "${old_logout_url}" ]] || [[ "$current_logout_url" == "" ]]
then
echo "
//-YunoHost-
// set logout_url according to main domain
\$main_domain = exec('cat /etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout';
\$main_domain = file_get_contents('/etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout&r=${url_base64}';
//-YunoHost-
" >> "$install_dir/config/config.php"
fi
#=================================================
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS

View file

@ -1,20 +1,31 @@
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index 13aef8f67a..55d8dbf9d1 100644
index aa6617c..eb47b80 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -97,11 +97,12 @@ class LoginController extends Controller {
@@ -111,16 +111,20 @@ class LoginController extends Controller {
#[UseSession]
public function logout() {
$loginToken = $this->request->getCookie('nc_token');
+ $uuidUser = $this->userSession->getUser()->getUID();
+ $isLdapUser = $this->config->getUserValue($uuidUser, 'user_ldap', 'uid');
if (!is_null($loginToken)) {
- $this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);
+ $this->config->deleteUserValue($uuidUser, 'login_token', $loginToken);
}
$this->userSession->logout();
-
- $response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute(
- 'core.login.showLoginForm',
- ['clear' => true] // this param the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers
+ $redirectUrl = $this->config->getSystemValue('logout_url',
+ $this->urlGenerator->linkToRouteAbsolute(
- ));
-
+ $redirectUrl = $this->urlGenerator->linkToRouteAbsolute(
+ 'core.login.showLoginForm',
+ ['clear' => true] // this param the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers)
));
-
+ );
+ if (!is_null($isLdapUser)) {
+ $redirectUrl = $this->config->getSystemValue('logout_url', $redirectUrl);
+ }
+ $response = new RedirectResponse($redirectUrl);
$this->session->set('clearingExecutionContexts', '1');
$this->session->close();