Skip to content

Commit

Permalink
added userID in Login
Browse files Browse the repository at this point in the history
  • Loading branch information
TottySnowman committed Oct 28, 2023
1 parent 787af85 commit 2878bb6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/src/controllers/index.ts
Expand Up @@ -33,21 +33,25 @@ app.get("/", async (req: Request, res: Response) => {

app.get("/login", async (req: Request, res: Response) => {
const { username, password } = req.query;

console.log(username, password);
const driver = await createDriver();

const session = driver.session();

const { records } = await session.run(
"MATCH (p:User {surname: $propertyValue, name: $password }) return p",
"MATCH (p:User {surname: $propertyValue, name: $password }) RETURN ID(p) AS userId, p",
{ propertyValue: username, password: password }
);

if (records.length <= 0) {
res.status(401).send("Login Failed!");
return;
}

res.status(200).send("Sucessfully logged in as " + username);
res.status(200).json({
message: "Successfully logged in!",
userID: records[0].get("userId").toInt(),
});
});

app.post("/history", async (req: Request, res: Response) => {
Expand Down

0 comments on commit 2878bb6

Please sign in to comment.