Skip to content

Commit 648995b

Browse files
fix: fix and improve oauth
1 parent ecf7b20 commit 648995b

19 files changed

Lines changed: 149 additions & 38 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from "react";
2+
import { createStyles, makeStyles } from "@material-ui/core/styles";
3+
import { Card, CardContent, Typography } from "@material-ui/core";
4+
5+
const useStyles = makeStyles(() =>
6+
createStyles({
7+
root: {
8+
margin: "2vh",
9+
minHeight: "20vh",
10+
width: "80vh",
11+
background: "#FFD166",
12+
},
13+
title: {
14+
fontSize: "1.2rem",
15+
color: "#3650C7",
16+
fontWeight: "bold",
17+
marginRight: "2vh",
18+
},
19+
lang: {
20+
opacity: 0.5,
21+
},
22+
body: {
23+
marginTop: "1vh",
24+
},
25+
owner: {
26+
marginTop: "1vh",
27+
opacity: 0.5,
28+
},
29+
})
30+
);
31+
32+
// interface MeetingCardProps {}
33+
34+
const MeetingCard: React.FC = ({}) => {
35+
const classes = useStyles();
36+
return (
37+
<Card className={classes.root}>
38+
<CardContent>
39+
<Typography>hello</Typography>
40+
</CardContent>
41+
</Card>
42+
);
43+
};
44+
45+
export default MeetingCard;

frontend/src/components/Meeting/MeetingTabs.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import AppBar from "@material-ui/core/AppBar";
55
import Tabs from "@material-ui/core/Tabs";
66
import Tab from "@material-ui/core/Tab";
77
import Box from "@material-ui/core/Box";
8+
import MeetingCard from "./MeetingCard";
89

910
interface TabPanelProps {
1011
children?: React.ReactNode;
@@ -81,10 +82,10 @@ const MeetingTabs: React.FC = () => {
8182
onChangeIndex={handleChangeIndex}
8283
>
8384
<TabPanel value={value} index={0} dir={theme.direction}>
84-
SecrET meETiNg
85+
<MeetingCard />
8586
</TabPanel>
8687
<TabPanel value={value} index={1} dir={theme.direction}>
87-
Pollllllling
88+
Polllllling
8889
</TabPanel>
8990
</SwipeableViews>
9091
</div>

frontend/src/components/Navs/Navbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Link, useHistory } from "react-router-dom";
1414
import MenuIcon from "@material-ui/icons/Menu";
1515
import { linklist } from "../linklist";
1616
import useTokenStore from "../../../store/tokenStore";
17-
import { logout } from "../../../utils/logout";
17+
import { logout } from "../../../utils/auth/logout";
1818

1919
const useStyles = makeStyles((theme: Theme) =>
2020
createStyles({

frontend/src/components/Navs/linklist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const linklist = [
2626
},
2727
{
2828
name: "Logout",
29-
url: "/registration",
29+
url: "/",
3030
loginReq: true,
3131
},
3232
];

frontend/src/components/Navs/navLinks/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import styles from "./style.module.css";
33
import { Link, useHistory } from "react-router-dom";
44
import { linklist } from "../linklist";
5-
import { logout } from "src/utils/logout";
5+
import { logout } from "src/utils/auth/logout";
66
import useTokenStore from "src/store/tokenStore";
77

88
const NavLinks: React.FC = () => {
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React, { useState } from "react";
2+
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
3+
import Dialog from "@material-ui/core/Dialog";
4+
import Typography from "@material-ui/core/Typography";
5+
import GoogleButton from "../Buttons/GoogleButton";
6+
import Login from "./Login";
7+
import ResetPassword from "./ResetPassword";
8+
import Signup from "./Signup";
9+
import { DialogContent } from "@material-ui/core";
10+
11+
const useStyles = makeStyles((theme: Theme) =>
12+
createStyles({
13+
title: {
14+
margin: "4vh",
15+
fontWeight: "bold",
16+
fontSize: "1.4rem",
17+
},
18+
main: {
19+
width: "30vw",
20+
[theme.breakpoints.down("sm")]: {
21+
width: "70vw",
22+
},
23+
},
24+
or: {
25+
margin: "2vh",
26+
},
27+
})
28+
);
29+
30+
interface AuthDialogProps {
31+
isOpen: boolean;
32+
}
33+
const AuthDialog: React.FC<AuthDialogProps> = ({ isOpen }) => {
34+
const classes = useStyles();
35+
const [page, setPage] = useState(0);
36+
const heading = ["Login", "Sign Up", "Reset Password"];
37+
const component = [
38+
<Login setPage={setPage} />,
39+
<Signup setPage={setPage} />,
40+
<ResetPassword setPage={setPage} />,
41+
];
42+
43+
return (
44+
<Dialog
45+
aria-labelledby="customized-dialog-title"
46+
open={isOpen}
47+
maxWidth={false}
48+
>
49+
<DialogContent className={classes.main}>
50+
<Typography className={classes.title} align="center">
51+
{heading[page]}
52+
</Typography>
53+
<GoogleButton />
54+
<Typography className={classes.or} align="center">
55+
OR
56+
</Typography>
57+
{component[page]}
58+
</DialogContent>
59+
</Dialog>
60+
);
61+
};
62+
63+
export default AuthDialog;

frontend/src/components/RegistrationForm/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button, Link, Typography } from "@material-ui/core";
44
import { useSignupLoginStyles } from "./signupLoginStyle";
55
import FormikTextField from "./FormikTextField";
66
import * as yup from "yup";
7-
import { fetchLogin } from "src/utils/fetchLogin";
7+
import { fetchLogin } from "../../utils/auth/fetchLogin";
88
import { useHistory } from "react-router";
99
import Snackbar from "@material-ui/core/Snackbar";
1010
import Alert from "@material-ui/lab/Alert";

frontend/src/components/RegistrationForm/ResetPassword.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button, Link, Typography } from "@material-ui/core";
44
import { useSignupLoginStyles } from "./signupLoginStyle";
55
import FormikTextField from "./FormikTextField";
66
import * as yup from "yup";
7-
import { resetPassword } from "src/utils/resetPassword";
7+
import { resetPassword } from "../../utils/auth/resetPassword";
88
import { useHistory } from "react-router";
99
import Snackbar from "@material-ui/core/Snackbar";
1010
import Alert from "@material-ui/lab/Alert";

frontend/src/components/RegistrationForm/Signup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button, Link, Typography } from "@material-ui/core";
44
import { useSignupLoginStyles } from "./signupLoginStyle";
55
import FormikTextField from "./FormikTextField";
66
import * as yup from "yup";
7-
import { fetchRegister } from "src/utils/fetchRegister";
7+
import { fetchRegister } from "../../utils/auth/fetchRegister";
88
import { useHistory } from "react-router";
99
import Snackbar from "@material-ui/core/Snackbar";
1010
import Alert from "@material-ui/lab/Alert";

frontend/src/pages/GoogleRedirect/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const GoogleRedirect: React.FC = () => {
2525
const setToken = useTokenStore((state) => state.setToken);
2626
React.useEffect(() => {
2727
const googleToken = async () => {
28-
const res = await fetch(server + "/api/user/google-login/" + id);
28+
const res = await fetch(server + "/api/user/google-login/" + id, {
29+
credentials: "include",
30+
});
2931
const payload = await res.json();
3032
if (payload.done) {
3133
setToken(payload.accessToken);
@@ -34,7 +36,6 @@ const GoogleRedirect: React.FC = () => {
3436
history.push("/registration");
3537
}
3638
};
37-
console.log("google redirect" + id);
3839
googleToken();
3940
}, []);
4041
return <div className={classes.root}>Loading...</div>;

0 commit comments

Comments
 (0)