feature: signup and login work
This commit is contained in:
parent
a4a750b35c
commit
3d42591ee5
18 changed files with 956 additions and 65 deletions
25
public/api/users/me/index.ts
Normal file
25
public/api/users/me/index.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { 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?.permissions.includes('self.read');
|
||||
|
||||
const has_permission = can_read_self;
|
||||
console.dir({
|
||||
meta,
|
||||
can_read_self,
|
||||
has_permission
|
||||
});
|
||||
if (!has_permission) {
|
||||
return CANNED_RESPONSES.permission_denied();
|
||||
}
|
||||
}];
|
||||
export function GET(_req: Request, meta: Record<string, any>): Response {
|
||||
return Response.json(meta.user, {
|
||||
status: 200
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue