mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2025-01-10 04:18:10 +02:00
[Web] fix incomplete session on broken logins
This commit is contained in:
parent
f36184df64
commit
83e53eb524
@ -2498,8 +2498,8 @@ function identity_provider($_action = null, $_data = null, $_extra = null) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$token = $iam_provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
|
$token = $iam_provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
|
||||||
$_SESSION['iam_token'] = $token->getToken();
|
$plain_token = $token->getToken();
|
||||||
$_SESSION['iam_refresh_token'] = $token->getRefreshToken();
|
$plain_refreshtoken = $token->getRefreshToken();
|
||||||
$info = $iam_provider->getResourceOwner($token)->toArray();
|
$info = $iam_provider->getResourceOwner($token)->toArray();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
$_SESSION['return'][] = array(
|
$_SESSION['return'][] = array(
|
||||||
@ -2538,6 +2538,8 @@ function identity_provider($_action = null, $_data = null, $_extra = null) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
set_user_loggedin_session($info['email']);
|
set_user_loggedin_session($info['email']);
|
||||||
|
$_SESSION['iam_token'] = $plain_token;
|
||||||
|
$_SESSION['iam_refresh_token'] = $plain_refreshtoken;
|
||||||
$_SESSION['return'][] = array(
|
$_SESSION['return'][] = array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
'log' => array(__FUNCTION__, $_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role']),
|
'log' => array(__FUNCTION__, $_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role']),
|
||||||
@ -2585,6 +2587,8 @@ function identity_provider($_action = null, $_data = null, $_extra = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_user_loggedin_session($info['email']);
|
set_user_loggedin_session($info['email']);
|
||||||
|
$_SESSION['iam_token'] = $plain_token;
|
||||||
|
$_SESSION['iam_refresh_token'] = $plain_refreshtoken;
|
||||||
$_SESSION['return'][] = array(
|
$_SESSION['return'][] = array(
|
||||||
'type' => 'success',
|
'type' => 'success',
|
||||||
'log' => array(__FUNCTION__, $_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role']),
|
'log' => array(__FUNCTION__, $_SESSION['mailcow_cc_username'], $_SESSION['mailcow_cc_role']),
|
||||||
@ -2595,8 +2599,8 @@ function identity_provider($_action = null, $_data = null, $_extra = null) {
|
|||||||
case "refresh-token":
|
case "refresh-token":
|
||||||
try {
|
try {
|
||||||
$token = $iam_provider->getAccessToken('refresh_token', ['refresh_token' => $_SESSION['iam_refresh_token']]);
|
$token = $iam_provider->getAccessToken('refresh_token', ['refresh_token' => $_SESSION['iam_refresh_token']]);
|
||||||
$_SESSION['iam_token'] = $token->getToken();
|
$plain_token = $token->getToken();
|
||||||
$_SESSION['iam_refresh_token'] = $token->getRefreshToken();
|
$plain_refreshtoken = $token->getRefreshToken();
|
||||||
$info = $iam_provider->getResourceOwner($token)->toArray();
|
$info = $iam_provider->getResourceOwner($token)->toArray();
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
clear_session();
|
clear_session();
|
||||||
@ -2618,8 +2622,9 @@ function identity_provider($_action = null, $_data = null, $_extra = null) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION['mailcow_cc_username'] = $info['email'];
|
set_user_loggedin_session($info['email']);
|
||||||
$_SESSION['mailcow_cc_role'] = "user";
|
$_SESSION['iam_token'] = $plain_token;
|
||||||
|
$_SESSION['iam_refresh_token'] = $plain_refreshtoken;
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
case "get-redirect":
|
case "get-redirect":
|
||||||
|
Loading…
Reference in New Issue
Block a user