Send IBM Domino User Information via a Node.js Application.

Mark Barton
InstructorMark Barton

Share this video with your friends

Send Tweet
Published 4 years ago
Updated 3 years ago

This lesson will demonstrate how to get information about the logged in user from Domino via a Node.js Express application, including user roles and the logged in users name.

It will utilise the Domino security session ID and deal with any authentication issues with sensible HTTP status codes.

Instructor: [00:00] To make use of the user roles we've got from Domino, we're going to go into our node application, our service.js. We're going to create a new route, and we're going to get hold of those roles. For now, for testing purposes, we'll have a direct route to load up the roles.

[00:14] Similar to previously, the first thing we need to do is get hold of the node DOM off social ID that we've set in our header. If we don't have one, we're going to bail because our application needs this authentication header. We'll set up the options. We're going to pass to our request promise.

[00:43] We also need to make sure that the request promise library actually returns JSON data. We do that by setting JSON true in the options. Our request promise will be called passing the options, and then we'll handle the response or any errors.

[01:01] We'll deconstruct the headers and bodies for the response, look for a Domino authentication failure. If we get pass that point, we'll just send back the actual response we get back from Domino, which should be some JSON data. We actually use the JSON method of express to send back correctly-formatted headers. If we get an error, we'll handle that, as well.

[01:25] We're now going to test this route in our client application. Going back into our index directional page, we're going to add a new button. We'll add it next to the get Domino data we had previously. This time we'll get user roles, or a new function called get user roles, and we'll write the script bot for that down here.

[01:42] First thing we do is set up an options object to pass to our Ajax call using the a-axis library. Our URL is going to be our new route, which is user roles. We'll pick up the node DOM off social ID that we've set in our local storage after we've logged in. Remember this won't work until you have logged in.

[02:09] We'll set up our custom header with a value, and now, we make our call using the a-axis library. For now, we're just going to log out the result which should be JSON data containing our user roles. We'll make sure to caption the areas, as well, and we'll also log those to the console. OK, we'll start our node server up, open the index page and test it.

[02:39] I fired up my node server, launched my index test page. Just to confirm, I still my have node DOM off social ID in my local storage. It's still a valid identification. If I click the get user roles button, look at my console, I get back some data.

[02:57] If I look in the network tab, I can now see that the response coming back is actually JSON data with the roles and my username. We can now use this data in our client application.