Node.js User Profile

Seed Project

Download a sample project. You will need to login for the sample to be preconfigured.

User Profile

Getting the user's profile information is very simple with Auth0. After the user has authenticated, a user object with the entire profile is attached to every express request.

Showing the User Profile

We can modify the /user endpoint to display the user object. Add the following to the views/user.jade template:

extends layout

block content
  h2 Welcome #{user.nickname}!
  a(href='/logout') Logout
  h2 User Profile
  pre #{userProfile}

To have full access to the user profile on userProfile, we need to strigify the user object. Modify the / endpoint in views/user.js to include userProfile.

// views/user.js

// Get the user profile
router.get('/', ensureLoggedIn, function(req, res, next) {
  res.render('user', {
    user: req.user ,
    userProfile: JSON.stringify(req.user, null, '  ')
Previous Tutorial
3. Custom Login
Try Auth0 for FREECreate free Account