base: Add feature flag for making articles api private
Some checks failed
/ deploy (push) Failing after -75h28m39s

This commit is contained in:
TheThing 2023-11-09 09:45:28 +00:00
parent d1730974dc
commit a5c7e53802
2 changed files with 12 additions and 1 deletions

View file

@ -8,11 +8,14 @@ export default class ArticleRoutes {
uploadMedia: uploadMedia, uploadMedia: uploadMedia,
uploadFile: uploadFile, uploadFile: uploadFile,
deleteFile: deleteFile, deleteFile: deleteFile,
requireAuth: opts.requireAuth,
}) })
} }
register(server) { register(server) {
server.flaska.get('/api/articles/:path', this.getArticle.bind(this)) if (!this.requireAuth) {
server.flaska.get('/api/articles/:path', this.getArticle.bind(this))
}
server.flaska.get('/api/auth/articles', server.authenticate(), this.auth_getAllArticles.bind(this)) server.flaska.get('/api/auth/articles', server.authenticate(), this.auth_getAllArticles.bind(this))
server.flaska.get('/api/auth/articles/:id', server.authenticate(), this.auth_getSingleArticle.bind(this)) server.flaska.get('/api/auth/articles/:id', server.authenticate(), this.auth_getSingleArticle.bind(this))
server.flaska.put('/api/auth/articles/:id', [ server.flaska.put('/api/auth/articles/:id', [
@ -111,6 +114,10 @@ export default class ArticleRoutes {
) )
} }
if (ctx.req.body.media && ctx.req.body.media.filename && ctx.req.body.media.type && ctx.req.body.media.path && ctx.req.body.media.size) {
newMedia = ctx.req.body.media
}
await Promise.all(promises) await Promise.all(promises)
return this.private_getUpdateArticle(ctx, ctx.req.body, newBanner, newMedia) return this.private_getUpdateArticle(ctx, ctx.req.body, newBanner, newMedia)

View file

@ -98,6 +98,10 @@ export default class Client {
} }
createJwt(body, secret) { createJwt(body, secret) {
return Client.createJwt(body, secret)
}
static createJwt(body, secret) {
let header = { let header = {
typ: 'JWT', typ: 'JWT',
alg: 'HS256', alg: 'HS256',