I am currently working on a project, where I have hardware device with some sensors etc., and web application, that can show the data to the user, and gives user some control over device.
One user can have many devices, so I need to make some sort of system, where user can add device to his account. And here is the part, where I have encountered an issue.
How can I know, that user has bought (or basically just owns) a device, that can be used with application?
My first thought was: Ok, just add some kind of key to each device, and tell the user to provide this, when they add device. But then I thought - how make sure that key is correct?
Should I make collections in my DB, where all proper keys are stored, check if key provided by user exists, remove key from DB and allow user to add device?
I am using:
to create my API. Do you have any suggestions?
Thanks for your time, and I wish you nice day :)
You should make a table of devices in your database. Then ask the user to add device id, then check
if user deviceid exists in devices table