feat: add functional authentication
This commit is contained in:
12
api/routes/auth/session.ts
Normal file
12
api/routes/auth/session.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { UnauthorizedError } from "@spec/relay/mod.ts";
|
||||
import { session } from "@spec/schemas/auth/routes.ts";
|
||||
|
||||
import { getAccountById } from "~stores/read-store/methods.ts";
|
||||
|
||||
export default session.access("session").handle(async ({ accountId }) => {
|
||||
const account = await getAccountById(accountId);
|
||||
if (account === undefined) {
|
||||
return new UnauthorizedError();
|
||||
}
|
||||
return account;
|
||||
});
|
||||
Reference in New Issue
Block a user