Files
auth-service/lib/middleware/authenication.ts

14 lines
328 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);
}
};
};