This function does 2 things: register a new user to Cotter and enroll the current device as a trusted device. Calling
enrollDevicefor a user ID that already exist in Cotter will result in the error "user already exist".
For example, this can happen when you:
- Call cotter.trustedDevice.enrollDevice from an already trusted device.
- Call cotter.trustedDevice.enrollDevice from a device B, when device A has already been registered as a trusted device.
Also note that
enrollDeviceonly works on the user's first ever trusted device. For additional trusted devices, you have to use the Add New Trusted Device method using the QR code.
getNewEventfetches a new un-approved authentication request that are generated when the user tries to login from a non-trusted device. However, since you're calling
getNewEventfrom a non-trusted device, this device cannot approve the request.
Will get errMsg: “Something went wrong”. You need a user that is registered to Cotter to be able to use any trusted device functionalities, except
enrollDevice(because that function will also register a new user to Cotter for you).
Will get err: “This device is not a trusted device.”