feature: chat is working?
This commit is contained in:
parent
b700251278
commit
200b89954b
9 changed files with 189 additions and 71 deletions
|
@ -6,8 +6,7 @@ import lurid from 'jsr:@andyburke/lurid';
|
|||
import { encodeBase64 } from 'jsr:@std/encoding';
|
||||
import parse_body from '../../../utils/bodyparser.ts';
|
||||
import { create_new_session, SESSION_RESULT } from '../auth/index.ts';
|
||||
import { PRECHECKS } from './me/index.ts';
|
||||
import { get_session, get_user, require_user } from '../../../utils/prechecks.ts';
|
||||
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../utils/prechecks.ts';
|
||||
import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
|
||||
|
||||
// TODO: figure out a better solution for doling out permissions
|
||||
|
@ -17,6 +16,8 @@ const DEFAULT_USER_PERMISSIONS: string[] = [
|
|||
'rooms.read'
|
||||
];
|
||||
|
||||
export const PRECHECKS: PRECHECK_TABLE = {};
|
||||
|
||||
// GET /api/users - get users
|
||||
// query parameters:
|
||||
// partial_id: the partial id subset you would like to match (remember, lurids are lexigraphically sorted)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import * as CANNED_RESPONSES from '../../../../utils/canned_responses.ts';
|
||||
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../../utils/prechecks.ts';
|
||||
|
||||
export const PERMISSIONS: Record<string, (req: Request, meta: Record<string, any>) => Promise<boolean>> = {};
|
||||
export const PRECHECKS: PRECHECK_TABLE = {};
|
||||
|
||||
// GET /api/users/me - Get the current user
|
||||
PRECHECKS.GET = [get_session, get_user, require_user, (_req: Request, meta: Record<string, any>): Response | undefined => {
|
||||
const can_read_self = meta.user.permissions.includes('self.read');
|
||||
console.dir({ meta, can_read_self });
|
||||
|
||||
if (!can_read_self) {
|
||||
return CANNED_RESPONSES.permission_denied();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue