Open NathanWEdwards opened 1 year ago
Pull request 5 introduces a context for representing authentication states within the application. A feature branch protected-api-call has been created, and is introduced in Pull request 34. A higher-order client component, ProtectedComponent, wraps around components that require authentication.
Further effort is needed to encapsulate content within the ProtectedComponent and guard against unintential execution of code within a ProtectedComponent when pages are accessed without authorization.
To minimize the amount of replicated code on pages and API routes for validating user authentication, a component that guards pages and routes, or a middleware, should be utilized.
JavaScript modules that employ a middleware design pattern NextAuth.js (soon to become Auth.js) and Passport.js offer convenient features to manage the request and response cycle of NodeJS applications in a few lines of code.