Skip to content

Conversation

@nickvergessen
Copy link
Member

No description provided.

@nickvergessen nickvergessen added this to the Nextcloud 26 milestone Oct 12, 2022
@nickvergessen nickvergessen changed the title Bugfix/noid/require token for local editing Require token for local editing Oct 12, 2022
@nickvergessen
Copy link
Member Author

/backport to stable25

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

$pathHash = sha1($path);

$entity = new OpenLocalEditor();
$entity->setUserId($this->userId);

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 1 of setUserId cannot be null, possibly null value provided
$pathHash = sha1($path);

try {
$entity = $this->mapper->verifyToken($this->userId, $pathHash, $token);

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 1 of OCA\Files\Db\OpenLocalEditorMapper::verifyToken cannot be null, possibly null value provided
*/
class OpenLocalEditor extends Entity {
/** @var string */
protected $userId;

Check notice

Code scanning / Psalm

PropertyNotSetInConstructor

Property OCA\Files\Db\OpenLocalEditor::$userId is not defined in constructor of OCA\Files\Db\OpenLocalEditor or in any methods called in the constructor
protected $userId;

/** @var string */
protected $pathHash;

Check notice

Code scanning / Psalm

PropertyNotSetInConstructor

Property OCA\Files\Db\OpenLocalEditor::$pathHash is not defined in constructor of OCA\Files\Db\OpenLocalEditor or in any methods called in the constructor
protected $pathHash;

/** @var int */
protected $expirationTime;

Check notice

Code scanning / Psalm

PropertyNotSetInConstructor

Property OCA\Files\Db\OpenLocalEditor::$expirationTime is not defined in constructor of OCA\Files\Db\OpenLocalEditor or in any methods called in the constructor
protected $expirationTime;

/** @var string */
protected $token;

Check notice

Code scanning / Psalm

PropertyNotSetInConstructor

Property OCA\Files\Db\OpenLocalEditor::$token is not defined in constructor of OCA\Files\Db\OpenLocalEditor or in any methods called in the constructor
* @throws MultipleObjectsReturnedException
* @throws Exception
*/
public function verifyToken(string $userId, string $pathHash, string $token): OpenLocalEditor {

Check notice

Code scanning / Psalm

MoreSpecificReturnType

The declared return type 'OCA\Files\Db\OpenLocalEditor' for OCA\Files\Db\OpenLocalEditorMapper::verifyToken is more specific than the inferred return type 'OCP\AppFramework\Db\Entity'
->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter($pathHash)))
->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)));

return $this->findEntity($qb);

Check notice

Code scanning / Psalm

LessSpecificReturnStatement

The type 'OCP\AppFramework\Db\Entity' is more general than the declared return type 'OCA\Files\Db\OpenLocalEditor' for OCA\Files\Db\OpenLocalEditorMapper::verifyToken
@nickvergessen nickvergessen merged commit eeeade0 into master Oct 12, 2022
@nickvergessen nickvergessen deleted the bugfix/noid/require-token-for-local-editing branch October 12, 2022 17:44
@nickvergessen nickvergessen self-assigned this Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants