Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/leadin/public/auth
File: class-oauth.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Leadin\auth;
[2] Fix | Delete
[3] Fix | Delete
use Leadin\data\User;
[4] Fix | Delete
use Leadin\data\Portal_Options;
[5] Fix | Delete
use Leadin\auth\OAuthCrypto;
[6] Fix | Delete
use Leadin\admin\Routing;
[7] Fix | Delete
use Leadin\admin\MenuConstants;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Class managing OAuth2 authorization
[11] Fix | Delete
*/
[12] Fix | Delete
class OAuth {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Authorizes the plugin with given oauth credentials by storing them in the options DB.
[16] Fix | Delete
*
[17] Fix | Delete
* @param string $refresh_token OAuth refresh token to store.
[18] Fix | Delete
*/
[19] Fix | Delete
public static function authorize( $refresh_token ) {
[20] Fix | Delete
$encrypted_refresh_token = OAuthCrypto::encrypt( $refresh_token );
[21] Fix | Delete
Portal_Options::set_refresh_token( $encrypted_refresh_token );
[22] Fix | Delete
[23] Fix | Delete
Portal_Options::set_last_authorize_time();
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Deauthorizes the plugin by deleting OAuth credentials from the options DB.
[28] Fix | Delete
*/
[29] Fix | Delete
public static function deauthorize() {
[30] Fix | Delete
Portal_Options::delete_refresh_token();
[31] Fix | Delete
[32] Fix | Delete
Portal_Options::set_last_deauthorize_time();
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Attempts to get and decrypt the refresh token.
[37] Fix | Delete
* Records an error if decryption fails or if the token is invalid.
[38] Fix | Delete
*
[39] Fix | Delete
* Note: WordPress sites that are missing keys and salts will have the refresh token stored in plaintext.
[40] Fix | Delete
* The decrypt function will return the plaintext token in this case.
[41] Fix | Delete
*
[42] Fix | Delete
* @return string The result of decrypt function, or an empty string on failure.
[43] Fix | Delete
*/
[44] Fix | Delete
public static function get_refresh_token() {
[45] Fix | Delete
$encrypted_refresh_token = Portal_Options::get_refresh_token();
[46] Fix | Delete
[47] Fix | Delete
if ( ! self::is_valid_value( $encrypted_refresh_token ) ) {
[48] Fix | Delete
return '';
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
$refresh_token = OAuthCrypto::decrypt( $encrypted_refresh_token );
[52] Fix | Delete
[53] Fix | Delete
if ( ! self::is_valid_value( $refresh_token ) ) {
[54] Fix | Delete
return false;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
return $refresh_token;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Checks if the provided value is valid (not false, null, or empty).
[62] Fix | Delete
*
[63] Fix | Delete
* @param mixed $value The value to check.
[64] Fix | Delete
* @return bool Whether the value is valid.
[65] Fix | Delete
*/
[66] Fix | Delete
private static function is_valid_value( $value ) {
[67] Fix | Delete
return false !== $value && null !== $value && '' !== $value;
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function