forked from Wavyzz/dolibarr
SQL tables for oauth
This commit is contained in:
@@ -120,4 +120,28 @@ class modOauth extends DolibarrModules
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when module is enabled.
|
||||||
|
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||||
|
* It also creates data directories
|
||||||
|
*
|
||||||
|
* @param string $options Options when enabling module ('', 'noboxes')
|
||||||
|
* @return int 1 if OK, 0 if KO
|
||||||
|
*/
|
||||||
|
function init($options='')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
// Clean before activation
|
||||||
|
$this->remove($options);
|
||||||
|
|
||||||
|
$sql = array(
|
||||||
|
"CREATE TABLE IF NOT EXISTS llx_oauth_state (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), state varchar(128), fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
|
||||||
|
"CREATE TABLE IF NOT EXISTS llx_oauth_token (rowid int(11) NOT NULL AUTO_INCREMENT, service varchar(36), token text, fk_user int(11), fk_adherent int(11), entity int(11), PRIMARY KEY (rowid)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;",
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->_init($sql,$options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ if (! empty($_GET['code'])) {
|
|||||||
// retrieve the CSRF state parameter
|
// retrieve the CSRF state parameter
|
||||||
$state = isset($_GET['state']) ? $_GET['state'] : null;
|
$state = isset($_GET['state']) ? $_GET['state'] : null;
|
||||||
try {
|
try {
|
||||||
//$token = $storage->retrieveAccessToken('Google');
|
$token = $storage->retrieveAccessToken('Google');
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
print $e->getMessage();
|
print $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,6 @@ class printing_printgcp extends PrintingDriver
|
|||||||
$storage->storeAccessToken('Google', $token);
|
$storage->storeAccessToken('Google', $token);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->errors[] = $e->getMessage();
|
$this->errors[] = $e->getMessage();
|
||||||
print '<pre>MissingRefreshToken: '.$e->getMessage().'</pre>';
|
|
||||||
//print '<pre>'.print_r($e,true).'</pre>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$conf->oauth->enabled) {
|
if (!$conf->oauth->enabled) {
|
||||||
@@ -212,8 +210,6 @@ class printing_printgcp extends PrintingDriver
|
|||||||
$storage->storeAccessToken('Google', $token);
|
$storage->storeAccessToken('Google', $token);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->errors[] = $e->getMessage();
|
$this->errors[] = $e->getMessage();
|
||||||
print '<pre>MissingRefreshToken: '.$e->getMessage().'</pre>';
|
|
||||||
//print '<pre>'.print_r($e,true).'</pre>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send a request with api
|
// Send a request with api
|
||||||
@@ -248,7 +244,7 @@ class printing_printgcp extends PrintingDriver
|
|||||||
function print_file($file, $module, $subdir='')
|
function print_file($file, $module, $subdir='')
|
||||||
{
|
{
|
||||||
global $conf, $user, $db;
|
global $conf, $user, $db;
|
||||||
// si $module=commande_fournisseur alors $conf->fournisseur->commande->dir_output
|
|
||||||
$fileprint=$conf->{$module}->dir_output;
|
$fileprint=$conf->{$module}->dir_output;
|
||||||
if ($subdir!='') $fileprint.='/'.$subdir;
|
if ($subdir!='') $fileprint.='/'.$subdir;
|
||||||
$fileprint.='/'.$file;
|
$fileprint.='/'.$file;
|
||||||
@@ -314,7 +310,7 @@ class printing_printgcp extends PrintingDriver
|
|||||||
'content' => base64_encode($contents), // encode file content as base64
|
'content' => base64_encode($contents), // encode file content as base64
|
||||||
'contentType' => $contenttype
|
'contentType' => $contenttype
|
||||||
);
|
);
|
||||||
// Token storage
|
// Dolibarr Token storage
|
||||||
$storage = new DoliStorage($this->db, $this->conf);
|
$storage = new DoliStorage($this->db, $this->conf);
|
||||||
// Setup the credentials for the requests
|
// Setup the credentials for the requests
|
||||||
$credentials = new Credentials(
|
$credentials = new Credentials(
|
||||||
|
|||||||
Reference in New Issue
Block a user