I am making a DApp where users need to be registered in the Solidity smart contract to perform some actions, for example:
function publish (string memory _itemURI) userOnly public {
// Publish item
}
Where the userOnly modifier is as follows
modifier userOnly {
require(users[msg.sender] == true, "User only");
_;
}
Registration is done with this function:
function register(address newUser) public {
users[newUser] = true;
emit Register(newUser);
}
The problem is: anyone could call the register function to register there own address, and then be able to call the userOnly functions. Is there a way the register function could only be called only at the end of our DApp sign-up process, like only after the user signs our terms of service with Metamask?