If the user is signed in through [Auth.signIn](/lib/auth/emailpassword#sign-in), then you can retrieve the current user's ID as shown below:

```js
const user = await Auth.currentAuthenticatedUser();

// sub is a unique identifier of the authenticated user
const userId = user.attributes.sub;
```
