From b70ac7c1836ce2fbfa4a9eb09dae47c22eabfb30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=B4=D0=B8=D0=BE=D0=BD?= Date: Sat, 14 Dec 2024 04:55:56 +0300 Subject: [PATCH] Feat: freetracker auth stubs --- server/routers/freetracker/auth/index.js | 24 +++++++++++++++++++ .../auth/json/login/login-error.json | 11 +++++++++ .../auth/json/login/login-success.json | 8 +++++++ .../json/registration/registration-error.json | 11 +++++++++ .../registration/registration-success.json | 9 +++++++ .../reset-password/reset-password-error.json | 11 +++++++++ .../reset-password-success.json | 8 +++++++ server/routers/freetracker/index.js | 3 ++- 8 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 server/routers/freetracker/auth/index.js create mode 100644 server/routers/freetracker/auth/json/login/login-error.json create mode 100644 server/routers/freetracker/auth/json/login/login-success.json create mode 100644 server/routers/freetracker/auth/json/registration/registration-error.json create mode 100644 server/routers/freetracker/auth/json/registration/registration-success.json create mode 100644 server/routers/freetracker/auth/json/reset-password/reset-password-error.json create mode 100644 server/routers/freetracker/auth/json/reset-password/reset-password-success.json diff --git a/server/routers/freetracker/auth/index.js b/server/routers/freetracker/auth/index.js new file mode 100644 index 0000000..a9401ce --- /dev/null +++ b/server/routers/freetracker/auth/index.js @@ -0,0 +1,24 @@ +const Router = require('express').Router + +const router = Router() + +router.post('/auth/login', (req, res) => { + if (req.body.email === 'qwerty@mail.ru') { + res.status(200).send(require('./json/login/login-success.json')) + } else { + res.status(401).send(require('./json/login/login-error.json')); + } +}) + +router.post('/auth/register', (req, res) => { + res.status(400).send(require('./json/registration/registration-error.json')) + // res.status(201).send(require('./json/registration/registration-error.json')) +}) + +router.post('/auth/reset-password', (req, res) => { + res.status(200).send(require('./json/reset-password/reset-password-success.json')) + // res.status(404).send(require('./json/reset-password/reset-password-error.json')) +}) + + +module.exports = router; diff --git a/server/routers/freetracker/auth/json/login/login-error.json b/server/routers/freetracker/auth/json/login/login-error.json new file mode 100644 index 0000000..b81e31a --- /dev/null +++ b/server/routers/freetracker/auth/json/login/login-error.json @@ -0,0 +1,11 @@ +{ + "success": false, + "body": null, + "errors": [ + { + "code": "AUTH_INVALID_CREDENTIALS", + "message": "Неверное имя пользователя или пароль" + } + ], + "warnings": [] +} diff --git a/server/routers/freetracker/auth/json/login/login-success.json b/server/routers/freetracker/auth/json/login/login-success.json new file mode 100644 index 0000000..6c331f0 --- /dev/null +++ b/server/routers/freetracker/auth/json/login/login-success.json @@ -0,0 +1,8 @@ +{ + "success": true, + "body": { + "token": "AUTH_TOKEN" + }, + "errors": [], + "warnings": [] +} diff --git a/server/routers/freetracker/auth/json/registration/registration-error.json b/server/routers/freetracker/auth/json/registration/registration-error.json new file mode 100644 index 0000000..13564af --- /dev/null +++ b/server/routers/freetracker/auth/json/registration/registration-error.json @@ -0,0 +1,11 @@ +{ + "success": false, + "body": null, + "errors": [ + { + "code": "REGISTRATION_EMAIL_TAKEN", + "message": "Электронная почта уже используется" + } + ], + "warnings": [] +} diff --git a/server/routers/freetracker/auth/json/registration/registration-success.json b/server/routers/freetracker/auth/json/registration/registration-success.json new file mode 100644 index 0000000..56559d8 --- /dev/null +++ b/server/routers/freetracker/auth/json/registration/registration-success.json @@ -0,0 +1,9 @@ +{ + "success": true, + "body": { + "userId": "12345", + "token": "AUTH_TOKEN" + }, + "errors": [], + "warnings": [] +} diff --git a/server/routers/freetracker/auth/json/reset-password/reset-password-error.json b/server/routers/freetracker/auth/json/reset-password/reset-password-error.json new file mode 100644 index 0000000..99915f9 --- /dev/null +++ b/server/routers/freetracker/auth/json/reset-password/reset-password-error.json @@ -0,0 +1,11 @@ +{ + "success": false, + "body": null, + "errors": [ + { + "code": "RESET_PASSWORD_EMAIL_NOT_FOUND", + "message": "Адрес электронной почты не зарегистрирован" + } + ], + "warnings": [] +} diff --git a/server/routers/freetracker/auth/json/reset-password/reset-password-success.json b/server/routers/freetracker/auth/json/reset-password/reset-password-success.json new file mode 100644 index 0000000..6102aa7 --- /dev/null +++ b/server/routers/freetracker/auth/json/reset-password/reset-password-success.json @@ -0,0 +1,8 @@ +{ + "success": true, + "body": { + "message": "Отправлено электронное письмо для сброса пароля" + }, + "errors": [], + "warnings": [] +} diff --git a/server/routers/freetracker/index.js b/server/routers/freetracker/index.js index 3d621fe..8fc129c 100644 --- a/server/routers/freetracker/index.js +++ b/server/routers/freetracker/index.js @@ -1,5 +1,6 @@ const router = require('express').Router(); router.use('/performer', require('./dashboard-performer')) +router.use('/auth', require('./auth')) -module.exports = router; \ No newline at end of file +module.exports = router; -- 2.45.2