diff options
author | bob <bcz@cs.brown.edu> | 2019-08-27 14:32:56 -0400 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-08-27 14:32:56 -0400 |
commit | 0341f6bb0d23e32ba2cb632fec3bf365ccd10047 (patch) | |
tree | 889731a2f9b6502fdf952d2cab5d77b6b0c149f2 /src/server/authentication | |
parent | 8b210d872e3a9c540825be0e9fbb912514092def (diff) | |
parent | 32f066ebc70684fe410b89fcb87cf550bd3537e3 (diff) |
Merge branch 'master' into bullets
Diffstat (limited to 'src/server/authentication')
-rw-r--r-- | src/server/authentication/config/passport.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/server/authentication/config/passport.ts b/src/server/authentication/config/passport.ts index d42741410..10b17de71 100644 --- a/src/server/authentication/config/passport.ts +++ b/src/server/authentication/config/passport.ts @@ -42,9 +42,11 @@ export let isAuthenticated = (req: Request, res: Response, next: NextFunction) = export let isAuthorized = (req: Request, res: Response, next: NextFunction) => { const provider = req.path.split("/").slice(-1)[0]; - if (_.find(req.user.tokens, { kind: provider })) { - next(); - } else { - res.redirect(`/auth/${provider}`); + if (req.user) { + if (_.find((req.user as any).tokens, { kind: provider })) { + next(); + } else { + res.redirect(`/auth/${provider}`); + } } };
\ No newline at end of file |