Express.js References:
Google Login via Passport.js References:
- Medium Article by @prashantramnyc
passport-google-oauth2
Package Docs- https://www.makeuseof.com/nodejs-google-authentication/
- https://github.com/kriscfoster/node-google-oauth-2/blob/master/index.js
From scratch:
npm install passport express-session passport-google-oauth2 --save
This isn't working when user visits other pages:
<% if (locals.user) { %>
<li class="nav-item">
<a class="nav-link" href="/user/profile">Profile</a>
</li>
<%} else { %>
<li class="nav-item">
<a class="nav-link" href="/login">Login</a>
</li>
<% } %>
... but here is a workaround: https://stackoverflow.com/questions/37183766/how-to-get-the-session-value-in-ejs
JavaScript dates:
<% order.order_at.toDate().toUTCString() %>
<% var myDate = order.order_at.toDate() %>
<% var y = myDate.getFullYear() %>
<% var m = String(myDate.getMonth() + 1).padStart(2, '0') %>
<% var d = String(myDate.getDate()).padStart(2, '0'); %>