Correzioni di stile
This commit is contained in:
parent
43203e5385
commit
4a93422974
|
@ -162,27 +162,6 @@ class OAuth2
|
|||
return unserialize($this->account->access_token);
|
||||
}
|
||||
|
||||
protected function checkTokens() {
|
||||
$access_token = unserialize($this->account->access_token);
|
||||
|
||||
if (!empty($access_token) && $access_token->hasExpired()) {
|
||||
// Tentativo di refresh del token di accesso
|
||||
$refresh_token = $this->account->refresh_token;
|
||||
if (!empty($refresh_token)) {
|
||||
$access_token = $this->getProvider()->getAccessToken('refresh_token', [
|
||||
'refresh_token' => $this->account->refresh_token,
|
||||
]);
|
||||
|
||||
$refresh_token = $access_token->getRefreshToken();
|
||||
} else {
|
||||
$access_token = null;
|
||||
$refresh_token = null;
|
||||
}
|
||||
|
||||
$this->updateTokens($access_token, $refresh_token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imposta l'access token per l'autenticazione OAuth2.
|
||||
*
|
||||
|
@ -194,4 +173,26 @@ class OAuth2
|
|||
$this->account->refresh_token = $refresh_token;
|
||||
$this->account->save();
|
||||
}
|
||||
|
||||
protected function checkTokens()
|
||||
{
|
||||
$access_token = unserialize($this->account->access_token);
|
||||
|
||||
if (!empty($access_token) && $access_token->hasExpired()) {
|
||||
// Tentativo di refresh del token di accesso
|
||||
$refresh_token = $this->account->refresh_token;
|
||||
if (!empty($refresh_token)) {
|
||||
$access_token = $this->getProvider()->getAccessToken('refresh_token', [
|
||||
'refresh_token' => $this->account->refresh_token,
|
||||
]);
|
||||
|
||||
$refresh_token = $access_token->getRefreshToken();
|
||||
} else {
|
||||
$access_token = null;
|
||||
$refresh_token = null;
|
||||
}
|
||||
|
||||
$this->updateTokens($access_token, $refresh_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,24 @@ switch (filter('op')) {
|
|||
'timeout' => post('timeout'),
|
||||
'ssl_no_verify' => post('ssl_no_verify'),
|
||||
'predefined' => $predefined,
|
||||
'provider' => $abilita_oauth2 ? post('provider') : null,
|
||||
'client_id' => $abilita_oauth2 ? post('client_id') : null,
|
||||
'client_secret' => $abilita_oauth2 ? post('client_secret') : null,
|
||||
'provider' => post('provider'),
|
||||
'client_id' => post('client_id'),
|
||||
'client_secret' => post('client_secret'),
|
||||
], ['id' => $id_record]);
|
||||
|
||||
flash()->info(tr('Informazioni salvate correttamente!'));
|
||||
|
||||
// Rimozione informazioni OAuth2 in caso di disabilitazione
|
||||
if (!$abilita_oauth2) {
|
||||
$dbo->update('em_accounts', [
|
||||
'provider' => null,
|
||||
'client_id' => null,
|
||||
'client_secret' => null,
|
||||
'access_token' => null,
|
||||
'refresh_token' => null,
|
||||
], ['id' => $id_record]);
|
||||
}
|
||||
|
||||
// Validazione indirizzo email mittente
|
||||
$check_email = Validate::isValidEmail(post('from_address'));
|
||||
|
||||
|
|
Loading…
Reference in New Issue