Almost every app requires a purchase restore option for its customers. If a customer transfers to different device, they will still have their purchase status saved.

  Based on this, we need to supply a method to identify a single customer across different devices. After a customer has been authenticated, he should be able to find all paid orders and restore it to a new device.

  Our platform provides a SMS login authentication solution. Each time a customer logs on to a new device, an authcode message will be acquired and evaluated. Additionally, in order to prevent customers from logging onto too many devices, we have set a maximum threshold N. Once the customer tries to logon to N+1 devices, the first device will be forced to automatically logout.

  Your main logic should look like the following: