Compare commits

..

15 Commits

Author SHA1 Message Date
02e50bb2f9 Merge pull request 'Update users.json' (#103) from dsf-fix-1 into master
Reviewed-on: #103
2025-02-08 14:26:13 +03:00
fadc62c8f0 Update users.json 2025-02-08 14:25:29 +03:00
4759f6f7ee Merge pull request 'Uncomment dogsitters app' (#102) from dsf-fix-1 into master
Reviewed-on: #102
2025-02-08 13:45:14 +03:00
14f2164a82 Uncomment dogsitters app 2025-02-08 13:44:34 +03:00
14ef1f9bad Merge pull request 'Fix export' (#101) from dsf-fix-1 into master
Reviewed-on: #101
2025-02-08 13:28:29 +03:00
dc99318ff0 Fix export 2025-02-08 13:27:38 +03:00
d2fc5f4d5c Merge pull request 'Fix dogsitters backend' (#100) from dsf-fix-1 into master
Reviewed-on: #100
2025-02-08 13:17:00 +03:00
938bd48fff Fix dogsitters backend 2025-02-08 13:15:02 +03:00
96f819dc91 Merge pull request 'fix' (#99) from sberhubproject into master
Reviewed-on: #99
2025-02-08 13:12:46 +03:00
25eee8adf5 fix
Some checks failed
platform/multy-stub/pipeline/head There was a failure building this commit
2025-02-08 13:10:58 +03:00
d2b2a29d3d Merge pull request 'Remove backend files' (#98) from dsf-fix-1 into master
Reviewed-on: #98
2025-02-08 13:10:27 +03:00
1cf71261d1 Remove backend files 2025-02-08 13:08:55 +03:00
88552eb04f Merge pull request 'Uncomment dogsitters app' (#97) from dsf-fix into master
Reviewed-on: #97
2025-02-08 12:49:30 +03:00
ab92c99321 Uncomment dogsitters app
Some checks failed
platform/multy-stub/pipeline/head There was a failure building this commit
2025-02-08 12:47:43 +03:00
02963de893 Merge pull request 'Изменение путей запросов' (#96) from dogsitters-finder-3 into master
Reviewed-on: #96
2025-02-08 12:41:38 +03:00
6 changed files with 73 additions and 160 deletions

View File

@@ -81,7 +81,7 @@ app.use(require("./root"))
app.use("/kfu-m-24-1", require("./routers/kfu-m-24-1"))
app.use("/epja-2024-1", require("./routers/epja-2024-1"))
app.use("/v1/todo", require("./routers/todo"))
// app.use("/dogsitters-finder", require("./routers/dogsitters-finder"))
app.use("/dogsitters-finder", require("./routers/dogsitters-finder"))
app.use("/kazan-explore", require("./routers/kazan-explore"))
app.use("/edateam", require("./routers/edateam-legacy"))
app.use("/dry-wash", require("./routers/dry-wash"))

View File

@@ -1,74 +0,0 @@
const { Router } = require("express");
const hash = require("pbkdf2-password")();
const { promisify } = require("node:util");
const jwt = require('jsonwebtoken')
const { getAnswer } = require("../../utils/common");
const { AuthModel } = require("./model/todo/auth");
const { TOKEN_KEY } = require('./const')
const { UserModel } = require("./model/todo/user");
const { requiredValidate } = require('./utils')
const router = Router();
router.post(
"/signup",
requiredValidate("login", "password", "email"),
async (req, res, next) => {
const { login, password, email } = req.body
const user = await AuthModel.findOne({ login });
if (user) {
throw new Error("Пользователь с таким логином уже существует");
}
hash({ password }, async function (err, pass, salt, hash) {
if (err) return next(err);
const user = await UserModel.create({ login, email });
await AuthModel.create({ login, hash, salt, userId: user.id });
res.json(getAnswer(null, { ok: true }))
})
}
)
function authenticate(login, pass, cb) {
AuthModel.findOne({ login }).populate('userId').exec().then((user) => {
if (!user) return cb(null, null)
hash({ password: pass, salt: user.salt }, function (err, pass, salt, hash) {
if (err) return cb(err)
if (hash === user.hash) return cb(null, user)
cb(null, null)
})
})
}
const auth = promisify(authenticate)
router.post('/signin', requiredValidate('login', 'password'), async (req, res) => {
const { login, password } = req.body
const user = await auth(login, password)
if (!user) {
throw new Error("Неверный логин или пароль")
}
const accessToken = jwt.sign({
...JSON.parse(JSON.stringify(user.userId)),
}, TOKEN_KEY, {
expiresIn: '12h'
})
res.json(getAnswer(null, {
user: user.userId,
token: accessToken,
}))
})
module.exports = router

View File

@@ -1,3 +1,2 @@
exports.DSF_AUTH_PASSWD_MODEL_NAME = 'DSF_AUTH_PASSWD'
exports.DSF_AUTH_USER_MODEL_NAME = 'DSF_AUTH_USER'
exports.DSF_INTERACTION_MODEL_NAME = 'DSF_INTERACTION'

View File

@@ -67,3 +67,5 @@ router.get("/auth/session", (request, response) => {
return response.status(403).json({ error: "Invalid token" });
}
});
module.exports = router

View File

@@ -1,13 +1,20 @@
[
{
"data": [
{
"id": 1,
"phone_number": 89283244141,
"phone_number": "89999999999",
"first_name": "Вася",
"second_name": "Пупкин",
"role": "dogsitter",
"location": "Россия, республика Татарстан, Казань, улица Пушкина, 12",
"price": 1500,
"about_me": "Я люблю собак"
"location": "Россия, республика Татарстан, Казань, Пушкина, 12",
"price": "1500",
"about_me": "Я люблю собак!",
"rating": 5,
"ratings": [
5,
5
],
"tg": "jullllllie"
},
{
"id": 2,
@@ -16,12 +23,18 @@
"second_name": "Пуськин",
"role": "dogsitter",
"location": "Россия, республика Татарстан, Казань, улица Абсалямова, 19",
"price": 1000000,
"about_me": "Я не люблю собак. И вообще я котоман."
"price": 2000,
"about_me": "Я не люблю собак. И вообще я котоман.",
"rating": 4,
"ratings": [
4,
4
],
"tg": "vanya006"
},
{
"id": 3,
"phone_number": 89872855893,
"phone_number": 89559999999,
"first_name": "Гадий",
"second_name": "Петрович",
"role": "owner"
@@ -33,7 +46,24 @@
"second_name": "Максим",
"role": "dogsitter",
"location": "Россия, республика Татарстан, Казань, проспект Ямашева, 83",
"price": 1000000,
"about_me": "Миллион алых роз"
"price": 1750,
"about_me": "Миллион алых роз",
"rating": 4.5,
"ratings": [
4,
5
],
"tg": "maks100500"
}
],
"interactions": [
{
"owner_id": 3,
"dogsitter_id": 4
},
{
"owner_id": 1,
"dogsitter_id": 2
}
]
}

View File

@@ -1,44 +0,0 @@
const { Schema, model } = require("mongoose");
const {
DSF_AUTH_PASSWD_MODEL_NAME,
DSF_AUTH_USER_MODEL_NAME,
} = require("../../const");
const schema = new Schema({
login: {
type: String,
required: true,
unique: true
},
hash: {
type: String,
required: true
},
salt: {
type: String,
required: true
},
userId: {
type: Schema.Types.ObjectId,
ref: DSF_AUTH_USER_MODEL_NAME
},
created: {
type: Date,
default: () => new Date().toISOString(),
},
});
schema.set("toJSON", {
virtuals: true,
versionKey: false,
transform: function (doc, ret) {
delete ret._id;
},
});
schema.virtual("id").get(function () {
return this._id.toHexString();
});
exports.AuthModel = model(DSF_AUTH_PASSWD_MODEL_NAME, schema);