Skip to content

Commit

Permalink
Merge pull request #22 from TeaByte/majhcc/issue21
Browse files Browse the repository at this point in the history
Fix sessionid issue
  • Loading branch information
m7medVision authored Jan 16, 2024
2 parents b166b3d + 2772dbd commit 7ef13c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion routes/_middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function handler(
const resp = await ctx.next();
const cookies = getCookies(req.headers);
const sessionId = cookies["sessionId"] || "";
if (!sessionId) {
if (sessionId == "") {
try {
const student = await createStudent();
const cookie: Cookie = {
Expand Down
7 changes: 7 additions & 0 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export const handler: Handlers<Props> = {
async GET(_req, ctx) {
const courses = await getCourses(cache);
const session = getCookies(_req.headers)["sessionId"];
if (!session) {
return ctx.render({
completed: [],
total: getNumberOfCourses(courses.courses),
courses: courses.courses,
});
}
const completed = (await getStudent(session)).completedCourses;
const total = getNumberOfCourses(courses.courses);
return ctx.render({
Expand Down

0 comments on commit 7ef13c0

Please sign in to comment.