diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-11-23 13:25:33 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-11-23 13:25:33 +0900 |
| commit | 767a292dbdaedeb34de5476f0c23ca25a0395e90 (patch) | |
| tree | 91669b7a99930967d0ec1699dec35730cb5483c5 /src/api/common | |
| parent | Improve readability (diff) | |
| download | sharkey-767a292dbdaedeb34de5476f0c23ca25a0395e90.tar.gz sharkey-767a292dbdaedeb34de5476f0c23ca25a0395e90.tar.bz2 sharkey-767a292dbdaedeb34de5476f0c23ca25a0395e90.zip | |
#939
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); + } +} |