diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-13 06:06:18 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-13 06:06:18 +0900 |
| commit | 3368fe855249f45bdf1e4c1e509d325d44e80fbe (patch) | |
| tree | 63c8bc61fb645b1d730b05120ab5117c0fdeee29 /src/server/api/common | |
| parent | wip (diff) | |
| download | sharkey-3368fe855249f45bdf1e4c1e509d325d44e80fbe.tar.gz sharkey-3368fe855249f45bdf1e4c1e509d325d44e80fbe.tar.bz2 sharkey-3368fe855249f45bdf1e4c1e509d325d44e80fbe.zip | |
wip
Diffstat (limited to 'src/server/api/common')
| -rw-r--r-- | src/server/api/common/signin.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/server/api/common/signin.ts b/src/server/api/common/signin.ts index 8bb327694d..f57c38414c 100644 --- a/src/server/api/common/signin.ts +++ b/src/server/api/common/signin.ts @@ -1,19 +1,20 @@ +import * as Koa from 'koa'; + import config from '../../../config'; +import { ILocalUser } from '../../../models/user'; -export default function(res, user, redirect: boolean) { +export default function(ctx: Koa.Context, user: ILocalUser, redirect: boolean) { const expires = 1000 * 60 * 60 * 24 * 365; // One Year - res.cookie('i', user.token, { + ctx.cookies.set('i', user.token, { path: '/', - domain: `.${config.hostname}`, - secure: config.url.substr(0, 5) === 'https', + domain: config.hostname, + secure: config.url.startsWith('https'), httpOnly: false, expires: new Date(Date.now() + expires), maxAge: expires }); if (redirect) { - res.redirect(config.url); - } else { - res.sendStatus(204); + ctx.redirect(config.url); } } |