-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfixedLogout.patch
47 lines (47 loc) · 1.49 KB
/
fixedLogout.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- a/usr/share/perl5/Lemonldap/NG/Portal/Main/Plugins.pm
+++ b/usr/share/perl5/Lemonldap/NG/Portal/Main/Plugins.pm
@@ -14,6 +14,7 @@ use Mouse;
# Developers: 2FA must be loaded before Notifications
# Developers: GlobalLogout must be the last loaded plugin
our @pList = (
+ fixedLogoutRedirection => '::Plugins::FixedRedirectOnLogout',
portalDisplayResetPassword => '::Plugins::MailPasswordReset',
portalDisplayCertificateResetByMail => '::Plugins::CertificateResetByMail',
portalStatus => '::Plugins::Status',
--- /dev/null
+++ b/usr/share/perl5/Lemonldap/NG/Portal/Plugins/FixedRedirectOnLogout.pm
@@ -0,0 +1,34 @@
+package Lemonldap::NG::Portal::Plugins::FixedRedirectOnLogout;
+
+use strict;
+use Mouse;
+use Lemonldap::NG::Portal::Main::Constants 'PE_OK';
+use URI;
+
+our $VERSION = '2.20.0';
+
+extends 'Lemonldap::NG::Portal::Main::Plugin';
+
+use constant beforeLogout => 'run';
+
+sub init {
+ my ($self) = @_;
+ if ( $self->conf->{fixedLogoutRedirection} ) {
+ my $host = URI->new($self->conf->{fixedLogoutRedirection})->host;
+ $self->conf->{trustedDomains} .= " $host";
+ $self->conf->{trustedDomains} =~ s/^ //;
+ }
+ return 1;
+}
+
+sub run {
+ my ( $self, $req ) = @_;
+ if ( $self->conf->{fixedLogoutRedirection} ) {
+ $self->logger->debug("Force logout redirection");
+ $req->mustRedirect(1);
+ $req->urldc( $self->conf->{fixedLogoutRedirection} );
+ }
+ return PE_OK;
+}
+
+1;