Skip to content

User vs Admin functions

The following operations are found in both provider.user and provider.admin:

  • getUser
  • isPayingUser
  • refund
  • subscription.get
  • subscription.getAll
  • subscription.cancel
  • subscription.reactivate

They do the same thing, yet require differenet parameters.

The functions from provider.user are using a session token of an authenticated user. NextJS and ExpressJS packages will automaticaly fetch the token from the cookies, so you can call the functions only with function’s specific parameters (instead of passing the token every time). For example calling the getUser from the user property:

Terminal window
//the token is automaticaly fetched by the package
provider.user.getUser()

These functions should be used inside endpoints that handle user specific actions, such as authentication, managing subscriptions, etc.

The functions from provider.admin don’t need a token. They only require an email adress or an id, which will be used to trigger the action on the chosen user. For example calling the getUser from the user property:

Terminal window
provider.admin.getUser('<email|id>')

These functions should be used on dashboards or by administrators. They are used internally by ProductFlame’s web dashboard, when you manage your users from there.