diff options
| author | Abdullah Ahmed <abdullah_ahmed@brown.edu> | 2019-08-28 21:06:02 -0400 |
|---|---|---|
| committer | Abdullah Ahmed <abdullah_ahmed@brown.edu> | 2019-08-28 21:06:02 -0400 |
| commit | 38c8b841dcf3f42b96b3d93e7bcc2fc6c9495613 (patch) | |
| tree | 9b0773f05ff9db5b67b47da398f2c16c2511f0bb /src/server/authentication/config | |
| parent | e03a1b2cc90e0fdb7789f4826e482e9040aa7075 (diff) | |
| parent | 4b7672c75fe5cdf6afe534e67213917b24980c3e (diff) | |
merged, docview still weird
Diffstat (limited to 'src/server/authentication/config')
| -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 |
