public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web] fix bug on mailbox login
4dc3222f
data/web/inc/functions.auth.inc.php | 18 ++++--------------
data/web/inc/functions.inc.php | 11 ++++++-----
data/web/inc/functions.mailbox.inc.php | 2 +-
3 files changed, 11 insertions(+), 20 deletions(-)
Diff
diff --git a/data/web/inc/functions.auth.inc.php b/data/web/inc/functions.auth.inc.php
index cd46b45b..88bdaf77 100644
--- a/data/web/inc/functions.auth.inc.php
+++ b/data/web/inc/functions.auth.inc.php
@@ -333,26 +333,16 @@ function keycloak_mbox_login_rest($user, $pass, $iam_settings, $is_internal = fa
return 'user';
}
- // try to create mbox on successfull login
- $mbox_template = null;
- // check if matching attribute mapping exists
- foreach ($iam_settings['mappers'] as $index => $mapper){
- if (in_array($mapper, $iam_settings['mappers'])) {
- $mbox_template = $iam_settings['templates'][$index];
- break;
- }
- }
- if (!$mbox_template){
- // no matching template found
- return false;
- }
+ // check if matching attribute exist
+ $mapper_key = array_search($user_template, $iam_settings['mappers']);
+ if ($mapper_key === false) return false;
// create mailbox
$create_res = mailbox('add', 'mailbox_from_template', array(
'domain' => explode('@', $user)[1],
'local_part' => explode('@', $user)[0],
'authsource' => 'keycloak',
- 'template' => $mbox_template
+ 'template' => $iam_settings['mappers'][$mapper_key]
));
if (!$create_res) return false;
diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php
index ef6fbec6..98991628 100644
--- a/data/web/inc/functions.inc.php
+++ b/data/web/inc/functions.inc.php
@@ -2316,7 +2316,7 @@ function identity_provider($_action, $_data = null, $_extra = null) {
);
return true;
}
-
+
// get mapped template, if not set return false
// also return false if no mappers were defined
$provider = identity_provider('get');
@@ -2330,9 +2330,10 @@ function identity_provider($_action, $_data = null, $_extra = null) {
);
return false;
}
-
+
// check if matching attribute exist
- if (array_search($user_template, $provider['mappers']) === false) {
+ $mapper_key = array_search($user_template, $provider['mappers']);
+ if ($mapper_key === false) {
clear_session();
$_SESSION['return'][] = array(
'type' => 'danger',
@@ -2341,13 +2342,13 @@ function identity_provider($_action, $_data = null, $_extra = null) {
);
return false;
}
-
+
// create mailbox
$create_res = mailbox('add', 'mailbox_from_template', array(
'domain' => explode('@', $info['email'])[1],
'local_part' => explode('@', $info['email'])[0],
'authsource' => identity_provider('get')['authsource'],
- 'template' => $user_template
+ 'template' => $provider['templates'][$mapper_key]
));
if (!$create_res){
clear_session();
diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index 7ba0a2f4..7ff1044a 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -1361,7 +1361,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
break;
}
}
-
+
return mailbox('add', 'mailbox', $mailbox_attributes, array('iam_create_login' => true));
break;
case 'resource':