13 lines
330 B
TypeScript
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);
|
|
}
|
|
};
|
|
};
|