Stuck on building voting app

I am stuck on the voting app project. I am following Clementinejs.

Github repo

I want a functionality that when a user has authenticated my app, I can send the data back to my app for rendering (So I can display the user’s github image for instance). I think that there may be 2 ways I can do this (I may be wrong)

  1. Upon successful authentication, when the app redirects to ‘/’, send the data that github sends, but so far, I have been unable to figure out how to do this, the relevant piece of code may be this in ./controllers/controller.js

     var path = require('path') 
    
     var data = [{name: 'abc'}, {name: 'def'}, {name: 'ghi'}]
    
     var mongoose = require('mongoose')
    
     var userSchema = require('../models/userSchema')
     var User = mongoose.model('User', userSchema)
    
     module.exports = function(app, passport){
     	app.get('/', function(req, res){
     		res.render('list', {polls: data})
     	})
    
     	app.get('/polls/:poll',function(req, res){
     		var poll = req.params.poll;
     		res.render('detail', {poll: dataDetail})
     	})
    
     	app.get('/login', function(req, res){
     		res.render('login')
     	})
    
     	app.get('/auth/github',passport.authenticate('github', { scope: [ 'user:email' ] }));
    
     	app.get('/auth/github/callback', 
     		passport.authenticate('github', { failureRedirect: '/login' }),
     			function(req, res) {
     				// Successful authentication, redirect home.
     				res.redirect('/');
     			});
     }
    
  2. Use front end JavaScript. When authentication is done, a POST request is made, and jQuery’s $.ajax function can be used like so, in ./static/js/auth.js

$(document).ready(function(){
$(‘form’).on(‘submit’, function(){
var item = $(‘form input’)
var d = {item: item.val()}

	$.ajax({
		type: 'POST',
		url: '/login',
		data: d,
		success: function(data) {
			console.log(data);
		}
	})
	return false
})

})

What can be done?