Skip to content

Commit 0d9553b

Browse files
Before authenticate user
1 parent 90c23c9 commit 0d9553b

File tree

4 files changed

+43
-11
lines changed

4 files changed

+43
-11
lines changed

apps/frontend/src/app/page.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ import TextArea from "antd/es/input/TextArea";
4444
import { title } from "process";
4545
import { isAuthenticated, isAdmin } from "@/utils/Auth";
4646
import { redirect } from 'next/navigation';
47+
import {
48+
ValidateUser,
49+
VerifyTokenResponseType,
50+
} from "./services/user";
4751

4852
/**
4953
* defines the State of the page whe a user is deleing an object. Has 3 general states:
@@ -119,12 +123,27 @@ export default function Home() {
119123
// State for refreshing data
120124
const [refresh, setRefresh] = useState(false);
121125

122-
useLayoutEffect(() => {
123-
const isAuth = isAuthenticated;
124-
if(!isAuth){
125-
redirect("/login")
126-
}
127-
}, [])
126+
// used to check if user jwt is verified
127+
128+
const [userId, setUserId] = useState<string | undefined>(undefined);
129+
const [email, setEmail] = useState<string | undefined>(undefined);
130+
const [username, setUsername] = useState<string | undefined>(undefined);
131+
const [isAdmin, setIsAdmin] = useState<boolean | undefined>(undefined);
132+
// useLayoutEffect(() => {
133+
// var isAuth = false;
134+
135+
// ValidateUser().then((data: VerifyTokenResponseType) => {
136+
// setUserId(data.data.id);
137+
// setEmail(data.data.email);
138+
// setUsername(data.data.username);
139+
// setIsAdmin(data.data.isAdmin);
140+
// isAuth = true;
141+
// }).finally(() => {
142+
// if(!isAuth){
143+
// redirect("/login")
144+
// }
145+
// });
146+
// }, [])
128147

129148
const handleEditClick = (index: number, question: Question) => {
130149
// Open the modal for the specific question

apps/user-service/MongoDBSetup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
![alt text](./GuideAssets/Selection4.png)
3535

36-
6. You will be prompted to set up Security for the database by providing `Username and Password`. Select that option and enter `Username` and `Password`. Please keep this safe as it will be used in User Service later on.
36+
6. You will be prompted to set up Security for the database by providing `Username and Password`. Select that option and enter `admin` and `admin_user_service`. Please keep this safe as it will be used in User Service later on.
3737

3838
![alt text](./GuideAssets/Security.png)
3939

apps/user-service/package-lock.json

Lines changed: 16 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/user-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"bcrypt": "^5.1.1",
2020
"cors": "^2.8.5",
2121
"dotenv": "^16.4.5",
22-
"express": "^4.19.2",
22+
"express": "^4.21.0",
2323
"jsonwebtoken": "^9.0.2",
2424
"mongoose": "^8.5.4"
2525
}

0 commit comments

Comments
 (0)