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

refactor: auth for server and client-side with middleware checks #447

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"name": "Next.js: debug client-side",
"type": "pwa-msedge",
"type": "msedge",
"request": "launch",
"url": "http://localhost:3000",
"cwd": "${workspaceFolder}/client"
Expand All @@ -21,7 +21,18 @@
"request": "launch",
"command": "yarn start",
"cwd": "${workspaceFolder}/client",
"console": "integratedTerminal",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithEdge"
}
},
{
"name": "Next.js: debug production stack",
"type": "node-terminal",
"request": "launch",
"command": "yarn start:prod",
"cwd": "${workspaceFolder}/client",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
Expand Down
1 change: 1 addition & 0 deletions client/env/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PORT=3000
# ----- ----- APOLLO GRAPHQL ----- -----

NEXT_PUBLIC_SERVER_ADDRESS=some-server-url
SERVER_ACCESS_API_KEY=some-api-key

# ----- ----- IMAGEKIT ----- -----

Expand Down
8 changes: 3 additions & 5 deletions client/src/components/admin/Sidebar/menulist/NavCollapse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
ListItemText,
Typography,
} from '@mui/material';
import {
FiberManualRecord,
KeyboardArrowDown,
KeyboardArrowUp,
} from '@mui/icons-material';
import FiberManualRecord from '@mui/icons-material/FiberManualRecord';
import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUp from '@mui/icons-material/KeyboardArrowUp';

// components
import NavItem from './NavItem';
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/admin/Sidebar/menulist/NavItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@mui/material';

// context
import { SidebarContext } from '../../../../context/SidebarContext';
import { SidebarContext } from '../../../../context/SidebarContextProvider';

const NavItem = ({ item, level }) => {
const theme = useTheme();
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/homepage/SocialMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import insta4 from '../../assets/images/instagram/insta4.jpeg';
import insta5 from '../../assets/images/instagram/insta5.jpeg';
import insta6 from '../../assets/images/instagram/insta6.jpeg';
import Image from 'next/image';
import { YouTube, Instagram } from '@mui/icons-material';
import YouTube from '@mui/icons-material/YouTube';
import Instagram from '@mui/icons-material/Instagram';

const INSTA_LINKS = [insta1, insta2, insta3, insta4, insta5, insta6];

Expand Down
6 changes: 4 additions & 2 deletions client/src/components/marginals/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ const Footer = () => {
name='month'
className={classes.archivesSelect}
onChange={(e) => setMonth(e.target.value)}
defaultValue={''}
>
<option value='' selected disabled hidden>
<option value='' disabled hidden>
<Typography variant='body1'>Month</Typography>
</option>
{ARCHIVES.months.map((month, key) => (
Expand All @@ -223,8 +224,9 @@ const Footer = () => {
name='year'
className={classes.archivesSelect}
onChange={(e) => setYear(e.target.value)}
defaultValue={''}
>
<option value='' selected disabled hidden>
<option value='' disabled hidden>
<Typography variant='body1'>Year</Typography>
</option>
{ARCHIVES.years.map((year, key) => (
Expand Down
7 changes: 4 additions & 3 deletions client/src/components/onboarding/stages/NewsletterSignup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ import newsletter from '../../../assets/images/onboarding/newsletter.png';
import { ONBOARDING } from '../../../assets/placeholder/onboarding';

//graphql
import { GraphClient } from '../../../config/ApolloClient';
import newsLetterSubscription from '../../../graphql/mutations/user/newsLetterSubscription';

//context
import authContext from '../../../context/auth/AuthContext';
import { authContext } from '../../../context/AuthContextProvider';
import { apolloContext } from '../../../context/ApolloContextProvider';

function NewsletterSignup({ onComplete, onSkip, tabletMatches }) {
const classes = useStyles();
// const router = useRouter();
const graphClient = useContext(apolloContext);

// Local States
const [isSigned, setIsSigned] = useState(false);
Expand All @@ -37,7 +38,7 @@ function NewsletterSignup({ onComplete, onSkip, tabletMatches }) {
const onSignup = async () => {
setIsSigned(true);

await GraphClient.mutate({
await graphClient.mutate({
mutation: newsLetterSubscription,
variables: {
userId: mid,
Expand Down
7 changes: 4 additions & 3 deletions client/src/components/onboarding/stages/SelectTopics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext, useState } from 'react';
import authContext from '../../../context/auth/AuthContext';
import { authContext } from '../../../context/AuthContextProvider';

// Hooks
import useToggle from '../../../hooks/useToggle';
Expand All @@ -15,8 +15,8 @@ import Button from '../../shared/button/Regular';
import { ONBOARDING } from '../../../assets/placeholder/onboarding';

//graphql
import { GraphClient } from '../../../config/ApolloClient';
import updateUserTopics from '../../../graphql/mutations/user/updateUserTopics';
import { apolloContext } from '../../../context/ApolloContextProvider';

function Topic({
topic,
Expand Down Expand Up @@ -64,6 +64,7 @@ function SelectTopics({ onComplete, onSkip, tabletMatches, setSnackbarData }) {
});

const { user } = useContext(authContext);
const graphClient = useContext(apolloContext);

const updateInterestedTopics = async (topics) => {
try {
Expand All @@ -80,7 +81,7 @@ function SelectTopics({ onComplete, onSkip, tabletMatches, setSnackbarData }) {
}
console.log(user);

await GraphClient.mutate({
await graphClient.mutate({
mutation: updateUserTopics,
variables: {
id: user.mid,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/onboarding/stages/VerifyEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import makeStyles from '@mui/styles/makeStyles';
import verifyEmailImg from '../../../assets/images/onboarding/verifyEmail.png';
// Constants
import { ONBOARDING } from '../../../assets/placeholder/onboarding';
import authContext from '../../../context/auth/AuthContext';
import { authContext } from '../../../context/AuthContextProvider';
// Components
import Button from '../../shared/button/Regular';
import Input from '../../shared/input/Regular';
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/onboarding/stages/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import logo from '../../../assets/images/logo.png';
// Constants
import { ONBOARDING } from '../../../assets/placeholder/onboarding';
//Context
import authContext from '../../../context/auth/AuthContext';
import { authContext } from '../../../context/AuthContextProvider';

function Welcome({
onSignIn,
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/shared/button/ScrollToTopButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';

import makeStyles from '@mui/styles/makeStyles';
import { Fab } from '@mui/material';
import { KeyboardArrowUp } from '@mui/icons-material';
import KeyboardArrowUp from '@mui/icons-material/KeyboardArrowUp';

const ScrollToTopButton = () => {
const classes = useStyles();
Expand All @@ -26,6 +26,7 @@ const ScrollToTopButton = () => {

useEffect(() => {
window.addEventListener('scroll', toggleVisible);
return () => window.removeEventListener('scroll', toggleVisible);
}, []);

return (
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/widgets/HomeCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React, { useState, useEffect } from 'react';

import makeStyles from '@mui/styles/makeStyles';
import { useSwipeable } from 'react-swipeable';
import { ArrowBack, ArrowForward } from '@mui/icons-material';
import ArrowBack from '@mui/icons-material/ArrowBack';
import ArrowForward from '@mui/icons-material/ArrowForward';

const HomeCarousel = ({ links }) => {
const classes = useStyles();
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/widgets/PostHolder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { PhoneOutlined } from '@mui/icons-material';
import PhoneOutlined from '@mui/icons-material/PhoneOutlined';
import { Grid, Typography } from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/widgets/SocietyCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';

import clsx from 'clsx';

import { ExpandMore } from '@mui/icons-material';
import ExpandMore from '@mui/icons-material/ExpandMore';
import {
Card,
CardActions,
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/widgets/Squiggles.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function Squiggles({ data }) {
</Button>
</div>
<div className={classes.squigglesTextWrapper}>
<p className={classes.squigglesText}>
<div className={classes.squigglesText}>
<MarkdownWrapper variant='body1' styles={classes.squigglesText}>
{data.content}
</MarkdownWrapper>
</p>
</div>
</div>
</div>
</CardContent>
Expand Down
84 changes: 0 additions & 84 deletions client/src/config/ApolloClient.js

This file was deleted.

19 changes: 0 additions & 19 deletions client/src/config/Root.js

This file was deleted.

Loading