This repository has been archived on 2023-05-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
auth/lib/server/middleware/authenication.ts
mifi 32bfbd7adc
All checks were successful
continuous-integration/drone/push Build is passing
Finishing touches to publish
2023-05-03 11:38:41 -04:00

13 lines
330 B
TypeScript

import { Middleware } from 'koa';
import { LOGIN_ROUTE } from '../../constants/env';
export const authenticated = (): Middleware => {
return (ctx, next) => {
if (ctx.isAuthenticated()) {
return next();
} else {
ctx.redirect(process.env.LOGIN_ROUTE || LOGIN_ROUTE);
}
};
};