server: add missing auth/deny endpoint

This endpoint is hinted at in the client, but is not actually defined
in the backend. This commit defines it.
This commit is contained in:
Johann150 2022-10-16 20:59:21 +02:00 committed by Gitea
parent 418c88bb8f
commit c65fdebe26
2 changed files with 40 additions and 0 deletions

View file

@ -67,6 +67,7 @@ import * as ep___ap_show from './endpoints/ap/show.js';
import * as ep___app_create from './endpoints/app/create.js'; import * as ep___app_create from './endpoints/app/create.js';
import * as ep___app_show from './endpoints/app/show.js'; import * as ep___app_show from './endpoints/app/show.js';
import * as ep___auth_accept from './endpoints/auth/accept.js'; import * as ep___auth_accept from './endpoints/auth/accept.js';
import * as ep___auth_deny from './endpoints/auth/deny.js';
import * as ep___auth_session_generate from './endpoints/auth/session/generate.js'; import * as ep___auth_session_generate from './endpoints/auth/session/generate.js';
import * as ep___auth_session_show from './endpoints/auth/session/show.js'; import * as ep___auth_session_show from './endpoints/auth/session/show.js';
import * as ep___auth_session_userkey from './endpoints/auth/session/userkey.js'; import * as ep___auth_session_userkey from './endpoints/auth/session/userkey.js';
@ -375,6 +376,7 @@ const eps = [
['app/create', ep___app_create], ['app/create', ep___app_create],
['app/show', ep___app_show], ['app/show', ep___app_show],
['auth/accept', ep___auth_accept], ['auth/accept', ep___auth_accept],
['auth/deny', ep___auth_deny],
['auth/session/generate', ep___auth_session_generate], ['auth/session/generate', ep___auth_session_generate],
['auth/session/show', ep___auth_session_show], ['auth/session/show', ep___auth_session_show],
['auth/session/userkey', ep___auth_session_userkey], ['auth/session/userkey', ep___auth_session_userkey],

View file

@ -0,0 +1,38 @@
import { AuthSessions } from '@/models/index.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
export const meta = {
tags: ['auth'],
requireCredential: true,
secure: true,
errors: {
noSuchSession: {
message: 'No such session.',
code: 'NO_SUCH_SESSION',
id: '9c72d8de-391a-43c1-9d06-08d29efde8df',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
token: { type: 'string' },
},
required: ['token'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const result = await AuthSessions.delete({
token: ps.token,
});
if (result.affected == 0) {
throw new ApiError(meta.errors.noSuchSession);
}
});