1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2024-12-23 02:04:46 +02:00

[Web] handle fatal errors on getAccessToken

This commit is contained in:
FreddleSpl0it 2023-05-25 12:32:47 +02:00 committed by DerLinkman
parent e4284b8e19
commit 85368971fd
No known key found for this signature in database
GPG Key ID: F109FD97469550A2

View File

@ -2144,6 +2144,9 @@ function identity_provider($_action, $_data = null, $_extra = null) {
$pdo->rollback();
return false;
}
if ($setting == "server_url" || $setting == "authorize_url" || $setting == "token_url" || $setting == "userinfo_url") {
$_data[$setting] = rtrim($_data[$setting], '/');
}
$stmt->bindParam(':key', $setting);
$stmt->bindParam(':value', $_data[$setting]);
@ -2271,15 +2274,6 @@ function identity_provider($_action, $_data = null, $_extra = null) {
try {
$token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
} catch (Exception $e) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__),
'msg' => array('login_failed', $e->getMessage())
);
return false;
}
try {
$_SESSION['iam_token'] = $token->getToken();
$_SESSION['iam_refresh_token'] = $token->getRefreshToken();
$info = $provider->getResourceOwner($token)->toArray();
@ -2291,7 +2285,6 @@ function identity_provider($_action, $_data = null, $_extra = null) {
);
return false;
}
// check if email address is given
if (empty($info['email'])) return false;
@ -2374,15 +2367,6 @@ function identity_provider($_action, $_data = null, $_extra = null) {
try {
$token = $provider->getAccessToken('refresh_token', ['refresh_token' => $_SESSION['iam_refresh_token']]);
} catch (Exception $e) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__),
'msg' => array('login_failed', $e->getMessage())
);
return false;
}
try {
$_SESSION['iam_token'] = $token->getToken();
$_SESSION['iam_refresh_token'] = $token->getRefreshToken();
$info = $provider->getResourceOwner($token)->toArray();