Initially, I set the request type to be "any", but upon realizing that it should not be "any" or "Request", I have decided to extend express-session in order to create a custom session type. How can I achieve this and incorporate the specified information into the request session?
access_token : string
userinfo: {
sub: 'Diur4_PcorTDFMRP99pgP9Qwkclxg4',
name: 'John Kay',
family_name: 'Kay',
given_name: 'John',
picture: 'https://graph.microsoft.com/v1.0/me/photo/$value',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cc86a3a4a2e287adb58caeada0adaeada0ade2afa3a1">[email protected]</a>'
}
isAuth:boolean
req.session.access_token = access_token;
req.session.userinfo = Userinformtion;
req.session.isAuth = true; //save session
const isAuth = (req:any, res: Response, next: NextFunction) => {
if (req.session.isAuth) {
next();
} else {
res.render("landing");
}
};