Api/v2/logs End point API

Hi,

  1. Can we retrieve the last_login field from api/v2/logs ?
    2.Can we quire the last_login related logs ?
  2. any other option to get the last_login details?

Hi,
please go through the link,

Hi,
I have added last login property in Rule as follows,
user.user_metadata = user.user_metadata || {};
// update the user_metadata that will be part of the response
user.user_metadata.lastLogin = user.user_metadata.lastLogin || {};
let fDate = dateFormat(new Date(user.user_metadata.lastLogin), “yyyy-mm-dd”);
let sDate = dateFormat(new Date(), “yyyy-mm-dd”);

let firstDate = new Date(fDate),
secondDate = new Date(sDate),
timeDifference = Math.abs(secondDate.getTime() - firstDate.getTime());
let differentDays = Math.ceil(timeDifference / (1000 * 3600 * 24));
if(differentDays === 0)
{
user.user_metadata.lastLogin = new Date();
// persist the user_metadata update
auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
.then(function(){
callback(null, user, context);
})
.catch(function(err){
callback(err);
});
}
else
{
return callback(new UnauthorizedError(user.email +‘: User account has been deactivated’));
}
callback(null, user, context);

after that we can retrieve that data through Api as mentioned in following link
https://auth0.com/docs/metadata/apis

under the topic
" Retrieve User Metadata"

Thanks a lot for sharing it with the rest of community!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.