Skip to content

Commit 8eddd46

Browse files
Diana/email authentication (#103)
* quick save * quick save * merge * add Authentication page * authenticated * remove warnings Co-authored-by: Tristan816la <[email protected]>
1 parent 88f6ddc commit 8eddd46

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

apicall.rest

+4-3
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,14 @@ Content-Type: application/json
121121

122122
###
123123
POST http://localhost:9000/posts/comments
124-
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYwZTkxOGI5OTAwNWZkMDAyNDkyNjVhMiIsIm5hbWUiOiJlbWJhcmsiLCJlbWFpbCI6ImVtYmFya3Rlc3RlcjEyMzRAZ21haWwuY29tIiwidXNlclR5cGUiOiJzdHVkZW50IiwiaWF0IjoxNjI3Njg4NjA4LCJleHAiOjE2MzYzMjg2MDh9.74rnAYLyQfaOIxazPHceDFseLbQFd4CrfDnx3SdDUaI
124+
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYwZTkxOGI5OTAwNWZkMDAyNDkyNjVhMiIsIm5hbWUiOiJlbWJhcmsiLCJlbWFpbCI6ImVtYmFya3Rlc3RlcjEyMzRAZ21haWwuY29tIiwiaWF0IjoxNjQyMjc0OTAxLCJleHAiOjE2NTA5MTQ5MDF9.CdkPEhx1JHr7lDL5U4W-LCzTVBDisOGTAFQa-rLTTSU
125125
Content-Type: application/json
126126

127127
{
128128
"authorID": "60e918b99005fd00249265a2",
129-
"post_id": "606e86b1791b49003a04c1e1",
130-
"commentBody": "nothing"
129+
"post_id": "5fbb8518a42d3a00dca56efb",
130+
"commentBody": "nothing",
131+
"authorName": "embark tester"
131132
}
132133

133134
###

src/App.js

+7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ import { LinkedInPopUp } from "react-linkedin-login-oauth2";
2828
import ViewClubProfile from "./pages/Profile/viewClubProfile";
2929
import ViewStudentProfile from "./pages/Profile/viewStudentProfile";
3030
import Moderation from "./pages/Moderation";
31+
import Authenticated from "./pages/Authenticated";
3132

3233
axios.defaults.baseURL =
34+
//"https:localhost:9000/";
3335
process.env.REACT_APP_BACKEND || "https://embark-backend-dev.herokuapp.com/";
3436

3537
const token = localStorage.getItem("AuthToken");
@@ -85,6 +87,11 @@ function App() {
8587
component={ViewStudentProfile}
8688
></Route>
8789
<Route path="/moderation" exact component={Moderation}></Route>
90+
<Route
91+
path="/auth/verifyAccount/:token"
92+
exact
93+
component={Authenticated}
94+
></Route>
8895
<Route path="/" component={ErrorPage}></Route>
8996
</Switch>
9097
</Router>

src/pages/Authenticated.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React, { useEffect, useState } from "react";
2+
import styled from "styled-components";
3+
import { ActionButton } from "../shared/Buttons";
4+
import { BoldTypography } from "../shared/Typography";
5+
import { useHistory } from "react-router-dom";
6+
import { useParams } from "react-router-dom";
7+
import axios from "axios";
8+
const HomeBtn = styled(ActionButton)`
9+
width: 148px;
10+
height: 47px;
11+
`;
12+
13+
const TextFieldWrapper = styled.div`
14+
display: flex;
15+
flex-direction: column;
16+
align-items: center;
17+
justify-content: center;
18+
gap: 10px;
19+
min-width: 450px;
20+
min-height: 300px;
21+
margin-top: 20px;
22+
padding: 10px;
23+
`;
24+
25+
const TextBox = styled.div`
26+
display: flex;
27+
text-align: center;
28+
justify-content: center;
29+
align-items: center;
30+
`;
31+
32+
const Authenticated = () => {
33+
const [verified] = useState(false);
34+
const history = useHistory();
35+
const { token } = useParams();
36+
useEffect(() => {
37+
const verify = async () => {
38+
const res = await axios.get(`/auth/verifyAccount/${token}`);
39+
console.log(res);
40+
};
41+
verify();
42+
}, [token]);
43+
return verified ? (
44+
<div>
45+
<TextFieldWrapper>
46+
<TextBox>
47+
<BoldTypography sz={"24px"}>Welcome to Embark!</BoldTypography>
48+
</TextBox>
49+
<TextBox>
50+
<BoldTypography sz={"18px"}>
51+
Your email address has been verified.
52+
</BoldTypography>
53+
</TextBox>
54+
<HomeBtn onClick={() => history.push("/home")}>Home</HomeBtn>
55+
</TextFieldWrapper>
56+
</div>
57+
) : (
58+
<div>
59+
<TextFieldWrapper>
60+
<TextBox>
61+
<BoldTypography sz={"24px"}>Verifying...</BoldTypography>
62+
</TextBox>
63+
</TextFieldWrapper>
64+
</div>
65+
);
66+
};
67+
68+
export default Authenticated;

0 commit comments

Comments
 (0)