Skip to content

Commit

Permalink
Make sure token getId returns an int for tests
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed May 11, 2023
1 parent a00e367 commit 4fce81e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/private/Authentication/Token/IToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface IToken extends JsonSerializable {
/**
* Get the token ID
*/
public function getId(): ?int;
public function getId(): int;

/**
* Get the user UID
Expand Down
8 changes: 6 additions & 2 deletions lib/private/Authentication/Token/PublicKeyToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ public function __construct() {
$this->addType('passwordInvalid', 'bool');
}

public function getId(): ?int {
return $this->id;
public function getId(): int {
if ($this->id !== null) {
return $this->id;
} else {
throw new \InvalidArgumentException('Cannot call getId on an token which was not inserted yet');
}
}

public function getUID(): string {
Expand Down

0 comments on commit 4fce81e

Please sign in to comment.