Authenticate from a Non-Trusted Device
Last updated
Last updated
There are 2 steps in authenticating a Non-Trusted Device
from the Non-Trusted Device and wait for approval
from a Trusted Device.
Same as how it works with , to authenticate a device, call the cotter?.loginWithTrustedDevice
function. This will automatically detect whether the current device is a Trusted Device or not.
Example:
JSON Result:
Event Name
The event
refers to what type of authentication event was requested. Example: LOGIN
event, TRANSACTION
event, UPDATE_PROFILE
event, etc.
Callback Class
The callback should be filled with the View Controller to go to when the request is approved. For example, if this is a login request, and the request is approved, then the callback can perform a segue to your Dashboard View Controller. Else, if the login completely failed (.failure
), then the callback can perform a segue to your 'Login Failed' View Controller.
When an Authentication Event is requested TRUSTED_DEVICE
, there are 2 possible cases:
If the current device is not a Trusted Device, then it will create a pending event. This pending event will need to be approved by a Trusted Device. You should see a JSON result looking like:
The SDK will automatically show a prompt for the user to approve the event from a Trusted Device.
Note: This is the flow for the user's trusted device to approve the login from the non-trusted device.
Example:
In the future, your app that is installed in a Trusted Device will receive a notification and this method is invoked when the notification is opened.
For now, you should tell your user to press a button and invoke this method when they try to login from a non-trusted device.
The SDK will open a prompt in the Trusted Device asking if the user want to approve or reject the authentication request
Note: This is the flow for the user's non-trusted device that requested the login.
If the login is approved, then an Error
does not exist, and you can redirect the user to, for instance, the Dashboard View Controller (Successful login).
Example:
However, if the request is not approved for 1 minute, the prompt in the Non-Trusted Device will show an error message (will auto-dismiss in 3 seconds). The prompt will not show an error immediately when the Trusted Device denied the request, i.e. there is no difference between rejection and no response from the Trusted Device.
In this case, after the prompt is dismissed, the user will remain on the same view where he/she started the prompted the authentication request.
You will be automatically approved if the request is coming from a Trusted Device. This is covered in .
To check if there's a pending event for this user, you can call the cotter?.getEventTrustedDevice
method from a Trusted Device. You can also when there's a new Login Request.
When the request is approved, the SDK will automatically redirect to your Callback function, which will be in the form of .