From 271f7cab7d5611681a73ad3bfcad3e314f4f6289 Mon Sep 17 00:00:00 2001 From: Alice Date: Wed, 25 Dec 2024 00:43:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=81=D1=82=D0=B0=D0=B1=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B4=D0=B2=D1=83=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/routers/dogsitters-finder/index.js | 59 ++++++++++--------- .../dogsitters-finder/json/2fa/error.json | 4 ++ .../dogsitters-finder/json/2fa/success.json | 4 ++ 3 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 server/routers/dogsitters-finder/json/2fa/error.json create mode 100644 server/routers/dogsitters-finder/json/2fa/success.json diff --git a/server/routers/dogsitters-finder/index.js b/server/routers/dogsitters-finder/index.js index 29a1e54..b34e6af 100644 --- a/server/routers/dogsitters-finder/index.js +++ b/server/routers/dogsitters-finder/index.js @@ -1,35 +1,40 @@ -const router = require('express').Router(); +const router = require("express").Router(); router.get("/users", (request, response) => { - response.send(require("./json/users/users.json")) -}) + response.send(require("./json/users/users.json")); +}); router.post("/auth", (request, response) => { - const {phoneNumber, password} = request.body; - console.log(phoneNumber, password); - if (phoneNumber === '89999999999') { - response.send(require("./json/auth/dogsitter.success.json")) - } - else if (phoneNumber === '89555555555') { - response.status(400).send(require("./json/auth/error.json")) - } - else { - response.send(require("./json/auth/owner.success.json")) - } -}) + const { phoneNumber, password } = request.body; + console.log(phoneNumber, password); + if (phoneNumber === "89999999999") { + response.send(require("./json/auth/dogsitter.success.json")); + } else if (phoneNumber === "89555555555") { + response.status(400).send(require("./json/auth/error.json")); + } else { + response.send(require("./json/auth/owner.success.json")); + } +}); + +router.post("/auth/2fa", (request, response) => { + const { code } = request.body; + if (code === "0000") { + response.send(require("./json/2fa/success.json")); + } else { + response.status(400).send(require("./json/2fa/error.json")); + } +}); router.post("/register", (request, response) => { - const {firstName, secondName, phoneNumber, password, role} = request.body; - console.log(phoneNumber, password, role); - if (phoneNumber === '89283244141' || phoneNumber === '89872855893') { - response.status(400).send(require("./json/register/error.json")) - } - else if (role === 'dogsitter') { - response.send(require("./json/register/dogsitter.success.json")) - } - else { - response.send(require("./json/register/owner.success.json")) - } -}) + const { firstName, secondName, phoneNumber, password, role } = request.body; + console.log(phoneNumber, password, role); + if (phoneNumber === "89283244141" || phoneNumber === "89872855893") { + response.status(400).send(require("./json/register/error.json")); + } else if (role === "dogsitter") { + response.send(require("./json/register/dogsitter.success.json")); + } else { + response.send(require("./json/register/owner.success.json")); + } +}); module.exports = router; diff --git a/server/routers/dogsitters-finder/json/2fa/error.json b/server/routers/dogsitters-finder/json/2fa/error.json new file mode 100644 index 0000000..7e4581e --- /dev/null +++ b/server/routers/dogsitters-finder/json/2fa/error.json @@ -0,0 +1,4 @@ +{ + "status": "error", + "message": "Invalid code." +} diff --git a/server/routers/dogsitters-finder/json/2fa/success.json b/server/routers/dogsitters-finder/json/2fa/success.json new file mode 100644 index 0000000..21e7111 --- /dev/null +++ b/server/routers/dogsitters-finder/json/2fa/success.json @@ -0,0 +1,4 @@ +{ + "status": "success", + "message": "Two-factor authentication passed." +} -- 2.45.2