1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-07-15 01:34:16 +02:00

fix keycloak mailpassword flow

This commit is contained in:
FreddleSpl0it
2023-09-26 16:06:35 +02:00
committed by DerLinkman
parent 73a044ec14
commit 3a4c0c84a3
3 changed files with 7 additions and 9 deletions

View File

@ -178,7 +178,7 @@ function user_login($user, $pass, $extra = null){
// user does not exist, try call keycloak login and create user if possible via rest flow
if (!$row){
$iam_settings = identity_provider('get');
if ($iam_settings['authsource'] == 'keycloak' && intval($iam_settings['mailboxpassword_flow']) == 1){
if ($iam_settings['authsource'] == 'keycloak' && intval($iam_settings['mailpassword_flow']) == 1){
$result = keycloak_mbox_login_rest($user, $pass, $iam_settings, array('is_internal' => $is_internal, 'create' => true));
if ($result !== false) return $result;
}
@ -190,7 +190,7 @@ function user_login($user, $pass, $extra = null){
if ($row['authsource'] == 'keycloak'){
// user authsource is keycloak, try using via rest flow
$iam_settings = identity_provider('get');
if (intval($iam_settings['mailboxpassword_flow']) == 1){
if (intval($iam_settings['mailpassword_flow']) == 1){
$result = keycloak_mbox_login_rest($user, $pass, $iam_settings, array('is_internal' => $is_internal));
return $result;
} else {
@ -367,8 +367,8 @@ function keycloak_mbox_login_rest($user, $pass, $iam_settings, $extra = null){
// get mapped template, if not set return false
// also return false if no mappers were defined
$user_template = $user_data['attributes']['mailcow_template'][0];
if ($create && (empty($iam_settings['mappers']) || $user_template)){
$user_template = $user_res['attributes']['mailcow_template'][0];
if ($create && (empty($iam_settings['mappers']) || !$user_template)){
return false;
} else if (!$create) {
// login success - dont create mailbox
@ -393,11 +393,6 @@ function keycloak_mbox_login_rest($user, $pass, $iam_settings, $extra = null){
));
if (!$create_res) return false;
// check if created mailbox from template is even active
// maybe dont even create it if active != 1
if ($mailbox_attributes['active'] != 1){
return false;
}
$_SESSION['return'][] = array(
'type' => 'success',