Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add authentication workflow #49

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bupemulenga13
Copy link
Contributor

@bupemulenga13 bupemulenga13 commented Nov 22, 2021

#33

  • Set Authentication Context(State Manager).
  • Build Api Server to Handle Requests to Backend API (API Middleware for Server Side Rendering).
  • Direct user to Login Page on entry(I need to detach default layout from Login/Register Page).
  • Index View Set to Dashboard.
  • Register button only visible to an authenticated user.
  • Register button to display pop-up modal on User listing.
  • Log out option to redirect the user to Login Page(functionality to logout user will be pushed in incoming PR).
  • Fix Default Layout render(Login and Registration successfully detached).
    NOTE:
    With current PR just pushed the following has been modified
  • Changed state manager from React Context to React-Redux (Redux gives us a single source of truth with a well-structured separation of concerns. On the other hand, Context requires us to place context code in every component that we work with, hence more code to maintain- speaking from experience).
  • Layout Fixed together with folder structure. I will send a brief layout on the slack channel as to the final structure to maintain.

src/config/routes.ts Outdated Show resolved Hide resolved
src/config/routes.ts Outdated Show resolved Hide resolved
src/config/routes.ts Outdated Show resolved Hide resolved
@sonlinux
Copy link
Contributor

Am cheking on the checkmarks in description
once they are all checked ill review again
thank you

"Content-Type": "application/json",
},
body: body,
});

console.log("Registration Payload" + JSON.stringify(body));

if (res.status === 200) {
if (res.status === 201) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not supposed to be a 301 redirect code upon a successful registration?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I could be wrong perhaps 301 would mean a redirect on failure, ill need to double-check this

.env Outdated
@@ -1 +1,2 @@
NODE_ENV=development
NEXT_PUBLIC_API_URL = 'https://localhost:8000'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are calling this ITEZ_API_URI in current upstream

try {
console.log("Try catch hit");
let body = JSON.stringify(user);
let res = await fetch(`/api/account/login`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensure we use SWR for all GET requests at most

});

try {
const apiRes = await fetch(`${API_URL}/api/user/`, {
const apiRes = await axios.post(`${config.ITEZ_API_URI}/api/users/`, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potential blocker here
This picks up ITEZ_APPI_URI from env vars meanwhile in there we have what is called NEXT_API_URL
so lets unify everything to ITEZ_API_URI and all should be streamlined properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants