1
0
mirror of https://github.com/microsoft/TypeScript-Node-Starter.git synced 2026-03-26 03:11:06 +00:00

Update packages, add tests, add type casts (#229)

- upgrade to latest packages
- cast `req.user` as `UserDocument`
- update logger to use latest Winston syntax
- disable `no-inferrable-types`, Mongoose use unified topology

Thx to @CarlosSolrac
This commit is contained in:
CarlosK
2019-09-29 05:31:07 -05:00
committed by Piotr Błażejewicz (Peter Blazejewicz)
parent 53ccb59f93
commit 1098943419
9 changed files with 1532 additions and 1158 deletions

View File

@@ -4,7 +4,7 @@ import passportFacebook from "passport-facebook";
import _ from "lodash";
// import { User, UserType } from '../models/User';
import { User } from "../models/User";
import { User, UserDocument } from "../models/User";
import { Request, Response, NextFunction } from "express";
const LocalStrategy = passportLocal.Strategy;
@@ -133,7 +133,8 @@ export const isAuthenticated = (req: Request, res: Response, next: NextFunction)
export const isAuthorized = (req: Request, res: Response, next: NextFunction) => {
const provider = req.path.split("/").slice(-1)[0];
if (_.find(req.user.tokens, { kind: provider })) {
const user = req.user as UserDocument;
if (_.find(user.tokens, { kind: provider })) {
next();
} else {
res.redirect(`/auth/${provider}`);