Commit dea4ba05 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'release/2.3' into 'master'

Release/2.3

See merge request !128
parents 6bc27a27 decfb3ef
......@@ -18,6 +18,7 @@
- `Fixed` Ajout d'un contact et/ou d'une adresse et/ou d'un moyen de communication aux organisations et services
## Version 2.2
### Exploitation
......
......@@ -103,4 +103,5 @@ INSERT INTO "auth"."privilege"("roleId", "userStory") VALUES
('UTILISATEUR', 'archiveRetrieval/*'),
('UTILISATEUR', 'archiveDeposit/*'),
('UTILISATEUR', 'archiveManagement/modify'),
('UTILISATEUR', 'archiveManagement/modifyDescription'),
('UTILISATEUR', 'adminArchive/filePlan');
......@@ -41,6 +41,7 @@ INSERT INTO "auth"."privilege"("roleId", "userStory") VALUES
('UTILISATEUR', 'archiveRetrieval/*'),
('UTILISATEUR', 'archiveDeposit/*'),
('UTILISATEUR', 'archiveManagement/modify'),
('UTILISATEUR', 'archiveManagement/modifyDescription'),
('UTILISATEUR', 'archiveManagement/filePlan');
......
......@@ -67,7 +67,9 @@ class csrf
$requestToken = $this->getRequestToken();
// Get account with LOCK
$account = $this->getAccount();
$this->sdoFactory->beginTransaction();
$account = $this->getAccount(true);
if (!$account) {
return;
}
......@@ -95,7 +97,12 @@ class csrf
$account->authentication->csrf = $accountTokens;
// Set account and COMMIT
$this->updateAccount($account);
try {
$this->updateAccount($account);
$this->sdoFactory->commit();
} catch (\Exception $exception) {
$this->sdoFactory->rollback();
}
return true;
}
......@@ -108,7 +115,7 @@ class csrf
*/
public function setResponseToken(&$response)
{
$account = $this->getAccount();
$account = $this->getAccount(false);
if (!$account) {
return;
}
......@@ -134,10 +141,11 @@ class csrf
/**
* Retrieves the account information with a LOCK on database
* @param bool $lock Lock user
*
* @return auth/userAccount
*/
private function getAccount()
private function getAccount($lock=false)
{
$accountToken = \laabs::getToken('AUTH');
......@@ -145,8 +153,7 @@ class csrf
return false;
}
$this->sdoFactory->beginTransaction();
$account = $this->sdoFactory->read('auth/account', $accountToken, $lock=true);
$account = $this->sdoFactory->read('auth/account', $accountToken, $lock);
$account->authentication = json_decode($account->authentication);
if (empty($account->authentication)) {
......@@ -240,7 +247,5 @@ class csrf
$account->authentication = json_encode($account->authentication);
$this->sdoFactory->update($account, "auth/account");
$this->sdoFactory->commit();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment