mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 06:04:25 +01:00
36 lines
767 B
JavaScript
36 lines
767 B
JavaScript
const ACL = require('../acl')
|
|
|
|
async function getBPRHandler (publicKey, req) {
|
|
}
|
|
|
|
async function addBPRHandler (publicKey, req) {
|
|
}
|
|
|
|
async function delBPRHandler (publicKey, req) {
|
|
}
|
|
|
|
async function parseBPRRequest(publicKey, req) {
|
|
if (!req) throw new Error('Request is empty')
|
|
const request = JSON.parse(req.toString())
|
|
const userId = await this.authenticate(publicKey, request)
|
|
|
|
const isOwner = ACL.getOwnder(repoName).includes(userId)
|
|
if (!isOwner) throw new Error('You are not allowed to access this repo')
|
|
|
|
const repoName = request.body.url?.split('/')?.pop()
|
|
// TODO: check if repo exists
|
|
|
|
return {
|
|
repoName,
|
|
userId,
|
|
// FIXME
|
|
acl: request.body.acl,
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
getBPRHandler,
|
|
addBPRHandler,
|
|
delBPRHandler,
|
|
}
|