From 0abc19fb859144b7dbcb81fdf7bbd55a718477a5 Mon Sep 17 00:00:00 2001 From: CanvasL <746591811@qq.com> Date: Tue, 30 Jul 2024 19:24:43 +0800 Subject: [PATCH] feat: isUserOwned acl --- src/AccessToken.sol | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/AccessToken.sol b/src/AccessToken.sol index 16a593c..dc96853 100644 --- a/src/AccessToken.sol +++ b/src/AccessToken.sol @@ -15,7 +15,7 @@ contract AccessToken is ERC721 { PRODUCT = product; } - modifier onlyTokenOwner(uint256 tokenId) { + modifier onlyProductOwner(uint256 tokenId) { require(msg.sender == PRODUCT.ownerOf(tokenId), "not product owner"); _; } @@ -23,15 +23,19 @@ contract AccessToken is ERC721 { function mint( address user, uint256 tokenId - ) external onlyTokenOwner(tokenId) { + ) external onlyProductOwner(tokenId) { _mint(user, tokenId); } - function burn(uint256 tokenId) external onlyTokenOwner(tokenId) { + function burn(uint256 tokenId) external onlyProductOwner(tokenId) { _burn(tokenId); } function isExist(uint256 tokenId) external view returns (bool) { return _ownerOf(tokenId) != address(0); } + + function isUserOwned(address user, uint256 tokenId) external view returns (bool) { + return _ownerOf(tokenId) == user; + } }