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

Michelle's Winter Break Work #424

Merged
merged 219 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 212 commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
c15a70f
change api name from /v2/ to /api/
michelleli01 Dec 26, 2023
26b409f
separate into folder
michelleli01 Dec 26, 2023
379e47c
set up db
michelleli01 Dec 27, 2023
e240e2f
fix api
michelleli01 Dec 27, 2023
531e4d5
unnecessary
michelleli01 Dec 27, 2023
404678d
unnecessary
michelleli01 Dec 27, 2023
ba60a3b
folders
michelleli01 Dec 27, 2023
de09000
reset routes
michelleli01 Dec 27, 2023
261f194
create routers
michelleli01 Dec 27, 2023
b963de4
stuff
michelleli01 Dec 28, 2023
e112cb1
search
michelleli01 Dec 28, 2023
1834918
searchbar functionality
michelleli01 Dec 28, 2023
2cdacc3
search complete
michelleli01 Dec 28, 2023
8318ac6
minor changes
michelleli01 Dec 28, 2023
c911399
profile complete
michelleli01 Dec 28, 2023
9a12afe
auth fixes
michelleli01 Dec 28, 2023
4ac6326
auth finished
michelleli01 Dec 28, 2023
f8ee704
thpes
michelleli01 Dec 28, 2023
aacfbea
minor changes
michelleli01 Dec 28, 2023
dd146c2
more validation
michelleli01 Dec 28, 2023
22c68a3
minor changes
michelleli01 Dec 28, 2023
2e1de3c
getCourseByInfo
michelleli01 Dec 28, 2023
964f068
course router
michelleli01 Dec 28, 2023
daec74b
see course details
michelleli01 Dec 28, 2023
95df623
review stuff
michelleli01 Dec 28, 2023
6ba72e7
review routes
michelleli01 Dec 29, 2023
a0831d1
fixing errors
michelleli01 Dec 29, 2023
7eca88f
review functionality
michelleli01 Dec 30, 2023
038f3db
review functionality fixed
michelleli01 Dec 30, 2023
37f28f2
admin testing
michelleli01 Dec 30, 2023
8cb04e3
abstract auth
michelleli01 Dec 30, 2023
41dbe36
name change
michelleli01 Dec 30, 2023
a9f06ec
stuff
michelleli01 Dec 30, 2023
927de7f
start admin stuff
michelleli01 Dec 30, 2023
2db3012
admin testing
michelleli01 Dec 30, 2023
dfc3185
auth fixes
michelleli01 Dec 30, 2023
ae89e23
minor changes
michelleli01 Dec 30, 2023
c2ba3a3
minor change
michelleli01 Dec 30, 2023
05056eb
fix fetch pending reviews
michelleli01 Dec 30, 2023
d215125
report review
michelleli01 Dec 30, 2023
2d007ea
get raffle winner
michelleli01 Dec 30, 2023
6af63da
init web scrapping
michelleli01 Dec 30, 2023
3ceb849
rename
michelleli01 Dec 30, 2023
e77f1c0
populate subjects and courses
michelleli01 Dec 31, 2023
e9bc745
wrap try/catch for null subjects and classes
michelleli01 Dec 31, 2023
90386b9
update names
michelleli01 Dec 31, 2023
ebd4912
minor change
michelleli01 Dec 31, 2023
4072542
add new semester functionality
michelleli01 Dec 31, 2023
ca90a51
add new sem core functionality done
michelleli01 Jan 3, 2024
1c69660
undo report review
michelleli01 Jan 3, 2024
4719874
remove review
michelleli01 Jan 3, 2024
acffbcd
set endpoints
michelleli01 Jan 3, 2024
1c2bf0f
reset professors
michelleli01 Jan 3, 2024
10ae0f8
reset professors
michelleli01 Jan 3, 2024
5e8490f
reset professors
michelleli01 Jan 4, 2024
3f0ad07
admin actions
michelleli01 Jan 8, 2024
d0ee59b
update
michelleli01 Jan 8, 2024
f4d567e
stuff
michelleli01 Jan 8, 2024
0bd035e
renaming
michelleli01 Jan 8, 2024
568dab1
report review functionality
michelleli01 Jan 8, 2024
a5bbac3
null fixes
michelleli01 Jan 8, 2024
a49d077
remove unnecessary dependency
michelleli01 Jan 8, 2024
332426a
build
michelleli01 Jan 9, 2024
ee1c933
types
michelleli01 Jan 9, 2024
64c9527
types
michelleli01 Jan 9, 2024
c0cab29
types
michelleli01 Jan 9, 2024
6b31567
types
michelleli01 Jan 9, 2024
425b5e8
types
michelleli01 Jan 9, 2024
a1de2a4
review controller logic
michelleli01 Jan 9, 2024
8900587
remove unnecessary dependencies
michelleli01 Jan 9, 2024
549c1f7
comment server build out
michelleli01 Jan 9, 2024
69cb4da
rename types
michelleli01 Jan 9, 2024
740d3b7
clean up admin
michelleli01 Jan 9, 2024
5acf504
add constants
michelleli01 Jan 9, 2024
29ef166
make more typesafe
michelleli01 Jan 9, 2024
e2667ab
make reviews more type safe
michelleli01 Jan 9, 2024
06954e1
make reviews more type safe
michelleli01 Jan 9, 2024
9df4d8a
add course sort
michelleli01 Jan 9, 2024
a8a7d6e
levenshtein algorithm
michelleli01 Jan 9, 2024
aeae0dd
levenshtein
michelleli01 Jan 9, 2024
41d821b
small changes
michelleli01 Jan 9, 2024
58d9431
confiure endpoints
michelleli01 Jan 9, 2024
54f40aa
drawing more boundaries
michelleli01 Jan 9, 2024
57feba8
set up test server
michelleli01 Jan 10, 2024
f74a9fa
search test
michelleli01 Jan 10, 2024
1cb6196
search functionality tests
michelleli01 Jan 10, 2024
59311c4
fix search
michelleli01 Jan 11, 2024
3852b0f
course unit tests
michelleli01 Jan 11, 2024
f20b0d3
review tests
michelleli01 Jan 11, 2024
f088277
auth tests
michelleli01 Jan 11, 2024
29c74b1
mocks
michelleli01 Jan 11, 2024
5b736d4
search tests
michelleli01 Jan 11, 2024
a9aac19
review tests
michelleli01 Jan 11, 2024
b66caab
auth tests
michelleli01 Jan 11, 2024
ec414a8
course tests
michelleli01 Jan 11, 2024
12c4a39
profile tests
michelleli01 Jan 11, 2024
97689db
remove console logs
michelleli01 Jan 11, 2024
4ffb914
mock server
michelleli01 Jan 11, 2024
2d9c675
admin tests
michelleli01 Jan 11, 2024
4af1884
course tests
michelleli01 Jan 11, 2024
a923a37
remove deprecated function
michelleli01 Jan 11, 2024
b3a1ec4
admin tests
michelleli01 Jan 11, 2024
7d7275c
deprecate admin chart tests
michelleli01 Jan 11, 2024
84d2aff
deprecate admin chart tests
michelleli01 Jan 11, 2024
e18f0b0
db scraping tests
michelleli01 Jan 11, 2024
4c8f777
remove unnecessary dependencies
michelleli01 Jan 11, 2024
4b6618b
don't add courses with only numbers in full name
michelleli01 Jan 11, 2024
a8454dc
github workflow
michelleli01 Jan 11, 2024
8a5b539
please build
michelleli01 Jan 11, 2024
0a0d04c
pls build part 2
michelleli01 Jan 11, 2024
893af16
git is to stupid
michelleli01 Jan 11, 2024
7c8e1bc
require token for adding new semester
michelleli01 Jan 11, 2024
20b8301
fixed scrapping
michelleli01 Jan 12, 2024
bafb206
fix test timeout
michelleli01 Jan 12, 2024
0d1907c
db init
michelleli01 Jan 12, 2024
f135140
fix raffle
michelleli01 Jan 12, 2024
c8a8cc4
admin page
michelleli01 Jan 12, 2024
ed927d2
admin page
michelleli01 Jan 12, 2024
099f1f2
routers
michelleli01 Jan 12, 2024
31c64f4
improved search functionality
michelleli01 Jan 12, 2024
a3b3aa9
added type
michelleli01 Jan 12, 2024
58543fa
minor changes
michelleli01 Jan 12, 2024
edaa11f
add report review test
michelleli01 Jan 12, 2024
ff95606
minor change
michelleli01 Jan 12, 2024
9fdb755
lint
michelleli01 Jan 12, 2024
03a1738
remove prettier
michelleli01 Jan 12, 2024
290d380
install cypress
michelleli01 Jan 12, 2024
d9cf436
cypress config
michelleli01 Jan 12, 2024
45f876c
cypress config
michelleli01 Jan 12, 2024
8035e7d
cypress search test
michelleli01 Jan 12, 2024
4130acb
professor search
michelleli01 Jan 12, 2024
70fff22
minor change
michelleli01 Jan 12, 2024
820f473
strange css styling
michelleli01 Jan 12, 2024
8f72332
improve search by including courses w profs.
michelleli01 Jan 12, 2024
84ef3a5
cross list stuff
michelleli01 Jan 12, 2024
51e2476
updating course metrics
michelleli01 Jan 12, 2024
a71cf29
crosslist courses and moving functions to utils
michelleli01 Jan 12, 2024
baf6d76
moving stuff around
michelleli01 Jan 12, 2024
c84c74f
rename
michelleli01 Jan 12, 2024
5e0c1e0
arrow functions and index for scripts
michelleli01 Jan 12, 2024
9784617
moving stuff around
michelleli01 Jan 12, 2024
0846f7b
export appropriate functions
michelleli01 Jan 12, 2024
f6546a6
arrow functions
michelleli01 Jan 12, 2024
66688e5
arrow functions
michelleli01 Jan 12, 2024
ac37b86
moving stuff around
michelleli01 Jan 12, 2024
f2bb506
final move (hopefully)
michelleli01 Jan 12, 2024
4e95558
minor changes
michelleli01 Jan 12, 2024
ee32726
make sure class metrics are being updated correctly
michelleli01 Jan 13, 2024
fc664ca
move
michelleli01 Jan 13, 2024
9e7a42a
remove config
michelleli01 Jan 13, 2024
fa962ba
fix bug where first time user going into profile fails
michelleli01 Jan 13, 2024
ca4231d
fixing null error
michelleli01 Jan 13, 2024
fdacc61
minor changes
michelleli01 Jan 13, 2024
7b3b99f
update test
michelleli01 Jan 13, 2024
42e511b
fix test
michelleli01 Jan 13, 2024
6c63eb4
remove unused functions
michelleli01 Jan 13, 2024
0ea8d66
mini bug
michelleli01 Jan 13, 2024
1351fc7
bug in mock
michelleli01 Jan 13, 2024
b84a9a4
db init and cross list work
michelleli01 Jan 13, 2024
603680d
documentation for populate courses
michelleli01 Jan 13, 2024
7ff9f11
populate professors documentation
michelleli01 Jan 13, 2024
1c293fc
populate subjects documentation
michelleli01 Jan 13, 2024
b798c8e
uils documentation
michelleli01 Jan 13, 2024
0b22ba6
uncomment important stuff
michelleli01 Jan 13, 2024
fc6bf78
documentation
michelleli01 Jan 13, 2024
527cb6d
crosslist
michelleli01 Jan 13, 2024
4bf74fe
lint
michelleli01 Jan 13, 2024
2edcdf2
small bug
michelleli01 Jan 13, 2024
e96236e
fix admin page real time update when buttons are clicked
michelleli01 Jan 13, 2024
d43e8a6
get raffle winner
michelleli01 Jan 13, 2024
e70ca1b
name changes
michelleli01 Jan 13, 2024
e9e6050
stop the unecessary failing calls to getStudentEmailByToken endpoinnt
michelleli01 Jan 13, 2024
d196644
more search tests
michelleli01 Jan 13, 2024
3b4102a
started create review test
michelleli01 Jan 13, 2024
629a609
remove duplicates from set and ensure not too big response object
michelleli01 Jan 13, 2024
6d02cb1
remove findAllCourses
michelleli01 Jan 13, 2024
fb60869
remove memory server
michelleli01 Jan 15, 2024
9dae034
fix search bar css
michelleli01 Jan 16, 2024
4201217
fix homepage css
michelleli01 Jan 16, 2024
deb1015
css modules for home screen
michelleli01 Jan 16, 2024
21484a6
mobile views
michelleli01 Jan 16, 2024
eb4f94b
remove profile dropdown navbar
michelleli01 Jan 16, 2024
ff7450c
profile dropdown to tsx
michelleli01 Jan 16, 2024
aeda662
review card
michelleli01 Jan 17, 2024
9fbfcad
adding css variables for more consistent colors
michelleli01 Jan 19, 2024
6aa2038
remove unnecessary css
michelleli01 Jan 19, 2024
b3f1b75
like reviews
michelleli01 Jan 19, 2024
ec0153f
fix review like functionality
michelleli01 Jan 19, 2024
f68cded
css variables
michelleli01 Jan 19, 2024
9b43836
remove console logs
michelleli01 Jan 19, 2024
e731332
remove console logs
michelleli01 Jan 19, 2024
593efd7
console log remove
michelleli01 Jan 19, 2024
67ee4e6
course module color variables
michelleli01 Jan 19, 2024
ddffeca
color variables
michelleli01 Jan 19, 2024
7657064
color consistency
michelleli01 Jan 19, 2024
29a99fc
color consistency
michelleli01 Jan 19, 2024
bc181ba
color changes based on sp22
michelleli01 Jan 19, 2024
f6e7f12
font sizing
michelleli01 Jan 19, 2024
453828e
minor change
michelleli01 Jan 19, 2024
9507b4a
fix minor styling issue
michelleli01 Jan 19, 2024
95e5afc
minor changes
michelleli01 Jan 19, 2024
00f081a
bring back editing button
michelleli01 Jan 19, 2024
255b328
fix up review container a bit
michelleli01 Jan 19, 2024
e894277
adjust results display
michelleli01 Jan 20, 2024
55d2b01
fix profile dropdown
michelleli01 Jan 20, 2024
9d8b5c3
mobile profile dropdown
michelleli01 Jan 20, 2024
3e5f2c9
edit homepage css
michelleli01 Jan 20, 2024
5e2e8f1
course page
michelleli01 Jan 20, 2024
a888ac7
small changes in results display
michelleli01 Jan 20, 2024
32b6708
user info card done
michelleli01 Jan 20, 2024
fe716eb
profile alignment
michelleli01 Jan 20, 2024
0be04d3
some profile changes
michelleli01 Jan 20, 2024
1563615
renaming messed up
michelleli01 Jan 21, 2024
f816ab2
minor comment
michelleli01 Jan 21, 2024
909fcca
admin controller comments
michelleli01 Jan 21, 2024
f83d507
auth controller comments
michelleli01 Jan 21, 2024
f8ebfb7
auth comments
michelleli01 Jan 21, 2024
948c4c4
search comments
michelleli01 Jan 21, 2024
64841b5
more comments
michelleli01 Jan 21, 2024
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@typescript-eslint/class-name-casing": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-function": "warn",
"import/prefer-default-export": "off",
"consistent-return": "warn",
"guard-for-in": "warn",
"import/extensions": "off",
Expand Down
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ Before this PR (i.e. on the main branch), there are X linter warnings. After my

<!--- List any important or subtle points, future considerations, or other items of note. -->

### Breaking Changes <!-- Optional -->
### Breaking Changes <!-- Optional -->

<!-- Keep items that apply: -->

- Database schema change (anything that changes Firestore collection structure)
- Other change that could cause problems (Detailed in notes)
2 changes: 1 addition & 1 deletion .github/workflows/ci-policies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
- uses: actions/checkout@master
- uses: cornell-dti/big-diff-warning@master
env:
BOT_TOKEN: '${{ secrets.BOT_TOKEN }}'
BOT_TOKEN: "${{ secrets.BOT_TOKEN }}"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mongodb-binaries/
.git
.vscode
.env
db
.meteor
mongo/
*error.log
Expand Down
7 changes: 2 additions & 5 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "course-reviews-react-2.0",
"scripts": {
},
"scripts": {},
"env": {
"MONGO_URL": {
"required": true
Expand All @@ -16,9 +15,7 @@
"quantity": 1
}
},
"addons": [
"papertrail"
],
"addons": ["papertrail"],
"buildpacks": [
{
"url": "heroku/nodejs"
Expand Down
2 changes: 1 addition & 1 deletion client/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
}
114 changes: 63 additions & 51 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,56 +1,68 @@
<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-111004890-1"
></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
// before React is loaded
// if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
// __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
// }
</script>
<script>
window.dataLayer = window.dataLayer || []

<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111004890-1"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script>
// before React is loaded
// if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'object') {
// __REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function() {};
// }
</script>
<script>
window.dataLayer = window.dataLayer || [];

function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());

gtag('config', 'UA-111004890-1');
</script>

<!--Graph search for facebook advertising-->

<meta property="og:image" content="http://image.ibb.co/jzN2cS/CUReviews_Ad.png" />
<meta property="og:image:alt" content="What will you find at CU Reviews? CUreviews.org" />
<meta property="og:description"
content="Help your friends and future Cornellians pick the best classes by providing honest and anonymous feedback about your experience." />
<meta property="og:title" content="CU Reviews" />
<meta property="og:url" content="https://www.cureviews.org" />
<meta property="og:type" content="website" />

<!-- Favicon support -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width,initial-scale=1.0">

<!-- Font Support -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,500,600&display=swap" rel="stylesheet">

<title>CU Reviews</title>
</head>

<body>
<div id="render-target" class="full-height"></div>
</body>
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())

gtag('config', 'UA-111004890-1')
</script>

<!--Graph search for facebook advertising-->

<meta
property="og:image"
content="http://image.ibb.co/jzN2cS/CUReviews_Ad.png"
/>
<meta
property="og:image:alt"
content="What will you find at CU Reviews? CUreviews.org"
/>
<meta
property="og:description"
content="Help your friends and future Cornellians pick the best classes by providing honest and anonymous feedback about your experience."
/>
<meta property="og:title" content="CU Reviews" />
<meta property="og:url" content="https://www.cureviews.org" />
<meta property="og:type" content="website" />

<!-- Favicon support -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />

<!-- Font Support -->
<link
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,500,600&display=swap"
rel="stylesheet"
/>

<title>CU Reviews</title>
</head>

<body>
<div id="render-target"></div>
</body>
</html>
34 changes: 17 additions & 17 deletions client/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
9 changes: 4 additions & 5 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
import React from 'react'


/* Importing Pages */
import { Home } from './modules/Home'
import { Course } from './modules/Course'
Expand All @@ -18,16 +17,16 @@ import { AuthRedirect } from './modules/AuthRedirect'
import 'bootstrap/dist/css/bootstrap.min.css'
import './index.css'

/**
A router is generated using the react-router-dom library.
This determines which component
/**
A router is generated using the react-router-dom library.
This determines which component
the user should see based on the URL they enter.

*/
const App = () => {
return (
<Router>
<div className="container-fluid full-height">
<div>
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/admin" component={Admin} />
Expand Down
14 changes: 7 additions & 7 deletions client/src/PrivateRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import * as React from "react";
import { Redirect, Route, RouteProps } from "react-router";
import * as React from 'react'
import { Redirect, Route, RouteProps } from 'react-router'

export type ProtectedRouteProps = {
isAuthenticated: boolean;
authenticationPath: string;
} & RouteProps;
isAuthenticated: boolean
authenticationPath: string
} & RouteProps

export default function ProtectedRoute({
isAuthenticated,
authenticationPath,
...routeProps
}: ProtectedRouteProps) {
if (isAuthenticated) {
return <Route {...routeProps} />;
return <Route {...routeProps} />
} else {
return <Redirect to={{ pathname: authenticationPath }} />;
return <Redirect to={{ pathname: authenticationPath }} />
}
}
70 changes: 36 additions & 34 deletions client/src/auth/auth_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,24 @@ export function useAuthMandatoryLogin(

if (!token || token === '') {
signIn(redirectFrom)
} else {
axios
.post('/api/getStudentEmailByToken', {
token: token,
})
.then((response) => {
const res = response.data
let verifiedEmail = ''

if (response.status === 200) {
verifiedEmail = res.result
}

setNetId(verifiedEmail.substring(0, verifiedEmail.lastIndexOf('@')))
})
.catch((e) => console.log(e.response))
}

axios
.post('/v2/getStudentEmailByToken', {
token: token,
})
.then((response) => {
const res = response.data.result
var verifiedEmail = ''

if (res.code === 200) {
console.log(res.message)
verifiedEmail = res.message
}

setNetId(verifiedEmail.substring(0, verifiedEmail.lastIndexOf('@')))
})
.catch((e) => console.log(e.response))

setToken(token)
setIsAuthenticating(false)
setIsLoggedIn(true)
Expand All @@ -92,26 +91,29 @@ export function useAuthOptionalLogin(): [
const token = getAuthToken()

if (token && token !== '') {
axios
.post('/api/getStudentEmailByToken', {
token: token,
})
.then((response) => {
const data = response.data
var verifiedEmail = ''

if (response.status === 200) {
verifiedEmail = data.result
}

const netId = verifiedEmail.substring(
0,
verifiedEmail.lastIndexOf('@')
)
setNetId(netId)
})
.catch((e) => console.log(e.response))

setToken(token)
setIsLoggedIn(true)
}

axios
.post('/v2/getStudentEmailByToken', {
token: token,
})
.then((response) => {
const res = response.data.result
var verifiedEmail = ''

if (res.code === 200) {
console.log(res.message)
verifiedEmail = res.message
}

setNetId(verifiedEmail.substring(0, verifiedEmail.lastIndexOf('@')))
})
.catch((e) => console.log(e.response))
}, [])

const signIn = (redirectFrom: string) => {
Expand Down
Loading
Loading