Manage devices
Amplify Auth enables you to track devices your users use for auditing, MFA, and more. Before you begin it is important to understand the terminology for device statuses:
- Tracked: Every time the user signs in with a new device, the client is given the device key at the end of a successful authentication event. We use this device key to generate a salt and password verifier which is used to call the ConfirmDevice API. At this point, the device is considered to be tracked. Once the device is in a tracked state, you can use the Amazon Cognito console to see the time it started to be tracked, last authentication time, and other information about that device.
- Remembered: Remembered devices are also tracked. During user authentication, the device key and secret pair assigned to a remembered device is used to authenticate the device to verify that it is the same device that the user previously used to sign in.
- Not Remembered: A not-remembered device is a tracked device where Cognito has been configured to require users to "Opt-in" to remember a device, but the user has not opt-ed in to having the device remembered. This use case is used for users signing into their application from a device that they don't own.
- Forgotten: a forgotten device is one removed from being remembered
Remember devices
You can remember devices using the following:
import { rememberDevice } from 'aws-amplify/auth';
await rememberDevice();
Forget devices
You can also forget devices but note that forgotten devices are neither remembered nor tracked.
import { forgetDevice } from 'aws-amplify/auth';
await forgetDevice();
Fetch devices
You can fetch a list of remembered devices by using the following:
import { fetchDevices } from 'aws-amplify/auth';
const output = await fetchDevices();
You can now set up devices to be remembered, forgotten, and fetched.