Last login fetch for list of users

We have a fetch via the REST api for a list of accounts based on query parameters. One of the required pieces of information that needs to be returned is the last login.

It seems that the last login is not attached to the account just the session. Is there a way of getting the last login dates for each account as part of the account fetch query? ie can you set a custom attribute with the last login or even change the user representation itself “under the hood”?

Looking to see what options there might be to and which would be the least painful.

You can implement an EventListener SPI to achieve that.
Simply listen to the LOGIN event and update the users attributes with a custom attribute and the current timestamp.