User login and verification. React native & Node.js(Express)

I am using Auth 0 for user authentication with React native.
In addition, Node.js (Express) is used for API on the server side.

We created and authenticated users from mobile applications and succeeded in verifying JWT on the server side.

However, it is not supported when you invalidate the user from the console screen of Auth 0 or when it is unconfirmed by mail address authentication.
Even in this case, JWT verification is possible on the server side, so it passes authentication.

In order to deal with this case, I think that it is necessary to make a request to the API of Auth 0 and check it.
For example, /userinfo endpoint.

Is my implementation considered generic?
Are there any reference page?

1 Like

Hey there @horota!

Totally got your usecase.I think that your approach with calling let’s say /userinfo endpoint will work totally.
Let me know if you’ve managed to implement it or you need further help!

1 Like

Thank you!
Since I was building a server side application(Node.js, Express), it seems to be solved also with Management API.

const ManagementClient = require('auth0').ManagementClient;
const auth0 = new ManagementClient({
  domain: AUTH0_DOMAIN,
  clientId: AUTH0_MANAGEMENT_CLIENT_ID,
  clientSecret: AUTH0_MANAGEMENT_CLIENT_SECRET,
  scope: 'read:users'
});

auth0.getUsers({id: req.user.sub}).then((data) => {
    if (data.blocked === true) {
      throw new Error('Blocked');
    }
    if (data.email_verified === false) {
      throw new Error('Email not verified');
    }
    next();
  }).catch((err) => {
    err.status = 401;
    next(err);
  })
1 Like

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

1 Like

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