@@ -6,7 +6,6 @@ import Router from "koa-router";
|
||||
import { AuthenticationError } from "@server/errors";
|
||||
import auth from "@server/middlewares/authentication";
|
||||
import { Collection, Team, View } from "@server/models";
|
||||
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'providers' implicitly has type 'any[]' i... Remove this comment to see the full error message
|
||||
import providers from "./providers";
|
||||
|
||||
const app = new Koa();
|
||||
@@ -14,7 +13,6 @@ const router = new Router();
|
||||
router.use(passport.initialize());
|
||||
|
||||
// dynamically load available authentication provider routes
|
||||
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'providers' implicitly has an 'any[]' typ... Remove this comment to see the full error message
|
||||
providers.forEach((provider) => {
|
||||
if (provider.enabled) {
|
||||
router.use("/", provider.router.routes());
|
||||
@@ -22,7 +20,7 @@ providers.forEach((provider) => {
|
||||
});
|
||||
|
||||
router.get("/redirect", auth(), async (ctx) => {
|
||||
const user = ctx.state.user;
|
||||
const { user } = ctx.state;
|
||||
const jwtToken = user.getJwtToken();
|
||||
|
||||
if (jwtToken === ctx.params.token) {
|
||||
@@ -45,10 +43,11 @@ router.get("/redirect", auth(), async (ctx) => {
|
||||
}),
|
||||
]);
|
||||
const hasViewedDocuments = !!view;
|
||||
|
||||
ctx.redirect(
|
||||
!hasViewedDocuments && collection
|
||||
? `${team.url}${collection.url}`
|
||||
: `${team.url}/home`
|
||||
? `${team!.url}${collection.url}`
|
||||
: `${team!.url}/home`
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user