mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 14:14:22 +01:00
@@ -147,7 +147,7 @@ module.exports = class RPC {
|
|||||||
|
|
||||||
async parseReq(publicKey, req) {
|
async parseReq(publicKey, req) {
|
||||||
if (!req) throw new Error('Request is empty')
|
if (!req) throw new Error('Request is empty')
|
||||||
let request = JSON.parse(req.toString())
|
const request = JSON.parse(req.toString())
|
||||||
const parsed = {
|
const parsed = {
|
||||||
repoName: request.body.url?.split('/')?.pop(),
|
repoName: request.body.url?.split('/')?.pop(),
|
||||||
branch: request.body.data?.split('#')[0],
|
branch: request.body.data?.split('#')[0],
|
||||||
@@ -159,10 +159,7 @@ module.exports = class RPC {
|
|||||||
|
|
||||||
async authenticate (publicKey, request) {
|
async authenticate (publicKey, request) {
|
||||||
if (!process.env.GIT_PEAR_AUTH) return publicKey.toString('hex')
|
if (!process.env.GIT_PEAR_AUTH) return publicKey.toString('hex')
|
||||||
if (process.env.GIT_PEAR_AUTH === 'naitive') return publicKey.toString('hex')
|
if (!request.header) throw new Error('You are not allowed to access this repo')
|
||||||
if (process.env.GIT_PEAR_AUTH !== 'naitive' && !request.header) {
|
|
||||||
throw new Error('You are not allowed to access this repo')
|
|
||||||
}
|
|
||||||
|
|
||||||
return (await auth.getId({ ...request.body, payload: request.header })).userId
|
return (await auth.getId({ ...request.body, payload: request.header })).userId
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user