Package breakdown - initial commit 1.0.0
This commit is contained in:
13
lib/middleware/authenication.ts
Normal file
13
lib/middleware/authenication.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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);
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user