Refactor to accommodate authentication, transaction and pagination states together (#4636)
* fix: refactor to accommodate authentication, transaction and pagination together into ctx.state * feat: allow passing response type to APIContext
This commit is contained in:
@@ -6,9 +6,10 @@ import Router from "koa-router";
|
||||
import { AuthenticationError } from "@server/errors";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { Collection, Team, View } from "@server/models";
|
||||
import { AppState, AppContext, APIContext } from "@server/types";
|
||||
import providers from "./providers";
|
||||
|
||||
const app = new Koa();
|
||||
const app = new Koa<AppState, AppContext>();
|
||||
const router = new Router();
|
||||
|
||||
router.use(passport.initialize());
|
||||
@@ -20,8 +21,8 @@ providers.forEach((provider) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/redirect", auth(), async (ctx) => {
|
||||
const { user } = ctx.state;
|
||||
router.get("/redirect", auth(), async (ctx: APIContext) => {
|
||||
const { user } = ctx.state.auth;
|
||||
const jwtToken = user.getJwtToken();
|
||||
|
||||
if (jwtToken === ctx.params.token) {
|
||||
|
||||
Reference in New Issue
Block a user