diff --git a/backend/src/api/user.ts b/backend/src/api/user.ts index c798c45..fdf8093 100644 --- a/backend/src/api/user.ts +++ b/backend/src/api/user.ts @@ -30,6 +30,9 @@ userRouter.get("/me", async (req: LRequest, res) => { delete copy._id; delete copy.hash; delete copy.salt; + delete copy.lastReview; + delete copy.lastLevel; + delete copy.vocabMetadata; res.send({ error: "0", diff --git a/backend/src/security/auth.ts b/backend/src/security/auth.ts index 6d0411f..5e031d1 100644 --- a/backend/src/security/auth.ts +++ b/backend/src/security/auth.ts @@ -27,15 +27,19 @@ export async function performLogin(username: string, password: string, db: Db): token: sessionToken, }); - return { - username: user.username, - uid: user.uid, - showWelcome: user.showWelcome, - score: user.score, - classId: user.classId, - + // Return the user, but remove all undeeded data + let copy = Object.assign({}, user, { sessionToken, - }; + }); + delete copy._id; + delete copy.hash; + delete copy.salt; + delete copy.lastReview; + delete copy.lastLevel; + delete copy.vocabMetadata; + + + return copy; } else { // It does not matter what we throw throw new Error("LOL"); diff --git a/frontend/src/containers/LevelList.ts b/frontend/src/containers/LevelList.ts index 15840bc..7aa0335 100644 --- a/frontend/src/containers/LevelList.ts +++ b/frontend/src/containers/LevelList.ts @@ -10,6 +10,7 @@ const mapStateToProps = state => { return { levels: state.levels, loading: state.levelList.loading, + user: state.user, }; }; const mapDispatchToProps = dispatch => { diff --git a/frontend/src/models/user.ts b/frontend/src/models/user.ts index 8090c60..03f5b0a 100644 --- a/frontend/src/models/user.ts +++ b/frontend/src/models/user.ts @@ -5,6 +5,9 @@ export interface IUser { score: number; classId: string; + // Levels that the user has completed + levels: number[]; + sessionToken: string; }; diff --git a/frontend/src/pages/levelList.tsx b/frontend/src/pages/levelList.tsx index cc5da60..90d7a26 100644 --- a/frontend/src/pages/levelList.tsx +++ b/frontend/src/pages/levelList.tsx @@ -12,10 +12,12 @@ import CircularProgress from "@material-ui/core/CircularProgress"; import { Link } from "react-router-dom"; import { ILevel } from "../models/level"; +import { IUser } from "../models/user"; interface IProps { getLevels: () => Promise; + user: IUser; setLevels: (levels: ILevel[]) => void; setLoading: (state: boolean) => void; loading: boolean; @@ -59,12 +61,13 @@ export default class Dashboard extends React.Component { let key = 0; const levelToCard = (level: ILevel) => { + const suffix = level.level in this.props.user.levels ? " ✔" : ""; return - {`Level ${level.level}`} + {`Level ${level.level}${suffix}`} {level.name}