remove legacy permission parsing

This commit is contained in:
Johann150 2022-07-24 11:45:37 +02:00
parent 3e05740bee
commit aba5b27159
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -23,6 +23,7 @@ export const paramDef = {
description: { type: 'string' },
permission: { type: 'array', uniqueItems: true, items: {
type: 'string',
// FIXME: add enum of possible permissions
} },
callbackUrl: { type: 'string', nullable: true },
},
@ -34,9 +35,6 @@ export default define(meta, paramDef, async (ps, user) => {
// Generate secret
const secret = secureRndstr(32, true);
// for backward compatibility
const permission = unique(ps.permission.map(v => v.replace(/^(.+)(\/|-)(read|write)$/, '$3:$1')));
// Create account
const app = await Apps.insert({
id: genId(),
@ -44,7 +42,7 @@ export default define(meta, paramDef, async (ps, user) => {
userId: user ? user.id : null,
name: ps.name,
description: ps.description,
permission,
permission: ps.permission,
callbackUrl: ps.callbackUrl,
secret: secret,
}).then(x => Apps.findOneByOrFail(x.identifiers[0]));