2024-12-25 00:43:36 +03:00
|
|
|
const router = require("express").Router();
|
2024-05-25 11:12:21 +03:00
|
|
|
|
|
|
|
router.get("/users", (request, response) => {
|
2024-12-25 00:43:36 +03:00
|
|
|
response.send(require("./json/users/users.json"));
|
|
|
|
});
|
2024-05-25 11:12:21 +03:00
|
|
|
|
2024-11-30 12:16:27 +03:00
|
|
|
router.post("/auth", (request, response) => {
|
2024-12-25 00:43:36 +03:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
});
|
2024-11-30 12:16:27 +03:00
|
|
|
|
|
|
|
router.post("/register", (request, response) => {
|
2024-12-25 00:43:36 +03:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
});
|
2024-11-30 12:16:27 +03:00
|
|
|
|
2024-05-25 11:12:21 +03:00
|
|
|
module.exports = router;
|