Route guard

PHOTO EMBED

Thu Aug 19 2021 18:54:07 GMT+0000 (UTC)

Saved by @ExplodeMilk #express #typescript

import {Request,Response,NextFunction} from 'express';

export function isLoggedIn(req:Request,res:Response,next:NextFunction){
    if(req.session?.['user']){
        next();
    }else{
        res.redirect('/login.html');
    }
}
content_copyCOPY