diff options
Diffstat (limited to 'src/api/common')
| -rw-r--r-- | src/api/common/signin.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/api/common/signin.ts b/src/api/common/signin.ts new file mode 100644 index 0000000000..693e62f39f --- /dev/null +++ b/src/api/common/signin.ts @@ -0,0 +1,19 @@ +import config from '../../conf'; + +export default function(res, user, redirect: boolean) { + const expires = 1000 * 60 * 60 * 24 * 365; // One Year + res.cookie('i', user.token, { + path: '/', + domain: `.${config.host}`, + secure: config.url.substr(0, 5) === 'https', + httpOnly: false, + expires: new Date(Date.now() + expires), + maxAge: expires + }); + + if (redirect) { + res.redirect(config.url); + } else { + res.sendStatus(204); + } +} |