2828
2929
3030class CredentialController extends ApiController {
31- private $ userId ;
32-
3331 public function __construct (
3432 $ AppName ,
3533 IRequest $ request ,
36- $ userId ,
37- private CredentialService $ credentialService ,
38- private ActivityService $ activityService ,
39- private CredentialRevisionService $ credentialRevisionService ,
40- private ShareService $ sharingService ,
41- private SettingsService $ settings ,
34+ private $ userId ,
35+ private readonly CredentialService $ credentialService ,
36+ private readonly ActivityService $ activityService ,
37+ private readonly CredentialRevisionService $ credentialRevisionService ,
38+ private readonly ShareService $ sharingService ,
39+ private readonly SettingsService $ settings ,
4240 ) {
4341 parent ::__construct (
4442 $ AppName ,
4543 $ request ,
4644 'GET, POST, DELETE, PUT, PATCH, OPTIONS ' ,
4745 'Authorization, Content-Type, Accept ' ,
4846 86400 );
49- $ this ->userId = $ userId ;
5047 }
5148
5249
@@ -146,8 +143,8 @@ public function updateCredential($changed, $created,
146143
147144
148145 if (!hash_equals ($ storedCredential ->getUserId (), $ this ->userId )) {
149- $ acl = $ this ->sharingService ->getCredentialAclForUser ($ this ->userId , $ storedCredential ->getGuid ());
150- if ($ acl ->hasPermission (SharingACL::WRITE )) {
146+ $ sharingAcl = $ this ->sharingService ->getACL ($ this ->userId , $ storedCredential ->getGuid ());
147+ if ($ sharingAcl ->hasPermission (SharingACL::WRITE )) {
151148 $ credential ['shared_key ' ] = $ storedCredential ->getSharedKey ();
152149 } else {
153150 return new DataResponse (['msg ' => 'Not authorized ' ], Http::STATUS_UNAUTHORIZED );
@@ -156,7 +153,7 @@ public function updateCredential($changed, $created,
156153 return new DataResponse (['msg ' => 'Not authorized ' ], Http::STATUS_UNAUTHORIZED );
157154 }
158155
159- if (!$ acl ->hasPermission (SharingACL::FILES )) {
156+ if (!$ sharingAcl ->hasPermission (SharingACL::FILES )) {
160157 // what ever the client transmitted, if it has no files permission, the previous files content will be preserved
161158 $ credential ['files ' ] = $ storedCredential ->getFiles ();
162159 }
@@ -199,7 +196,7 @@ public function updateCredential($changed, $created,
199196
200197 try {
201198 $ acl_list = $ this ->sharingService ->getCredentialAclList ($ storedCredential ->getGuid ());
202- } catch (\Exception $ exception ) {
199+ } catch (\Exception ) {
203200 // Just check if we have an acl list
204201 }
205202 if (!empty ($ acl_list )) {
@@ -264,7 +261,7 @@ public function updateCredential($changed, $created,
264261 public function deleteCredential ($ credential_guid ) {
265262 try {
266263 $ credential = $ this ->credentialService ->getCredentialByGUID ($ credential_guid , $ this ->userId );
267- } catch (\Exception $ e ) {
264+ } catch (\Exception ) {
268265 return new NotFoundJSONResponse ();
269266 }
270267 if ($ credential instanceof Credential) {
@@ -285,7 +282,7 @@ public function deleteCredential($credential_guid) {
285282 public function getRevision ($ credential_guid ) {
286283 try {
287284 $ credential = $ this ->credentialService ->getCredentialByGUID ($ credential_guid );
288- } catch (\Exception $ ex ) {
285+ } catch (\Exception ) {
289286 return new NotFoundJSONResponse ();
290287 }
291288 // If the request was made by the owner of the credential
@@ -320,7 +317,7 @@ public function updateRevision($revision_id, $credential_data) {
320317 $ revision = null ;
321318 try {
322319 $ revision = $ this ->credentialRevisionService ->getRevision ($ revision_id );
323- } catch (\Exception $ exception ) {
320+ } catch (\Exception ) {
324321 return new JSONResponse ([]);
325322 }
326323
0 commit comments