Cryptlex Forums

Get users without licenses

C
cartesiam

Hello,

Is it possible, using Cryptlex API, to get the list of users without any licenses?

Thanks

A
Adnan KamiliCryptlex team

Hi,

Can you please mention your use case?

Regards,
Adnan

C
cartesiam

Hello,

The use case is to clean expired licenses.
We were thinking of 2 steps:

  1. Delete expired licenses (with some time delta)
  2. Delete users without licenses (i.e. a user might have another active license, in that case user is not deleted)

Regards

A
Adnan KamiliCryptlex team

Hi,

You can filter licenses using the email address and if it returns an empty array that means the user has no license.

C
cartesiam

Ok thank you.

So, with that solution we need to loop over all users. That is what we were thinking of. We were just wondering if there was a one call solution.

A
Adnan KamiliCryptlex team

You don’t have to loop over all the users. At the time of deletion of the expired license,

const expiredLicenses = GET /v3/licenses?expired=true

for (let license in expiredLicenses)
{
DELETE /v3/licenses/license.id
GET /v3/licenses?email=license.user.email
If the above GET returns an empty array
DELETE /v3/users/<license.user.id>
}

C
cartesiam

Hello,

Indeed, it’s a better solution.

Thanks!

← Back to all topics · 7 posts · 1222 views · opened 2021-01-29