From 9085af3bd51e5cffc7c6ec60e7dc8eb5ba5fc013 Mon Sep 17 00:00:00 2001 From: TIVMOF <78173711+TIVMOF@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:19:50 +0200 Subject: [PATCH] Delete dirigible-bank-server-api directory --- dirigible-bank-server-api/project.json | 1 - dirigible-bank-server-api/user.ts | 76 -------------------------- 2 files changed, 77 deletions(-) delete mode 100644 dirigible-bank-server-api/project.json delete mode 100644 dirigible-bank-server-api/user.ts diff --git a/dirigible-bank-server-api/project.json b/dirigible-bank-server-api/project.json deleted file mode 100644 index fcc5a67..0000000 --- a/dirigible-bank-server-api/project.json +++ /dev/null @@ -1 +0,0 @@ -{"guid":"dirigible-bank-server-api"} \ No newline at end of file diff --git a/dirigible-bank-server-api/user.ts b/dirigible-bank-server-api/user.ts deleted file mode 100644 index 8900c5b..0000000 --- a/dirigible-bank-server-api/user.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { rs } from "sdk/http"; -// import { session } from "sdk/http"; -import { UsersRepository } from "/dirigible-bank-server/gen/dao/users/UsersRepository.ts"; - -const usersRepo = new UsersRepository(); - -rs.service({ - "login": { - "post": [ - { - "serve": (_ctx, request, response) => { - const body = request.getJSON(); - - response.println(body); - - ["Username", "Password"].forEach((field) => { - if (!(field in body)) { - response.setStatus(400); - response.println("Required more parameters"); - return; - } - }); - - const filterOptions = { - $filter: { - equals: { - Username: body.Username, - }, - }, - }; - - response.println(filterOptions); - - const existingUsers = usersRepo.findAll(filterOptions); - - response.println(existingUsers); - - if (existingUsers.length <= 0) { - response.setStatus(404); // User not found - response.println("User not found"); - return; - } else { - const user = existingUsers[0]; - - if (user.Password === body.Password) { - // Set session attributes - // session.setAttribute("userId", user.Id); // Save user ID in the session - // session.setAttribute("username", user.Username); - - // Return session-related data in the response - // const sessionData = { - // userId: user.Id, - // sessionId: session.getId(), // You can return the session ID - // }; - - response.setStatus(200); - response.setContentType("application/json"); - response.println(JSON.stringify(user.Id)); - - // response.println(JSON.stringify(sessionData)); // Include session data in the response - } else { - response.setStatus(401); - response.println("Invalid password"); - return; - } - } - }, - - "catch": (_ctx, err, _request, response) => { - response.println("Pesho"); - response.println(err); - } - }, - ], - } -}).execute()