summaryrefslogtreecommitdiff
path: root/src/server/api/common
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-11-28 05:27:34 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-11-28 05:27:34 +0900
commitf2578539067ff00e16d9f98415e00287a397dd35 (patch)
treec15f2503afd685309f75a1c5061afd9e6b61fb28 /src/server/api/common
parentAdd theme_color and 512x512 icon to app manifest (#3417) (diff)
downloadsharkey-f2578539067ff00e16d9f98415e00287a397dd35.tar.gz
sharkey-f2578539067ff00e16d9f98415e00287a397dd35.tar.bz2
sharkey-f2578539067ff00e16d9f98415e00287a397dd35.zip
Update signin.ts
Diffstat (limited to 'src/server/api/common')
-rw-r--r--src/server/api/common/signin.ts26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/server/api/common/signin.ts b/src/server/api/common/signin.ts
index 3a5ba0ea04..ddfd5f2bba 100644
--- a/src/server/api/common/signin.ts
+++ b/src/server/api/common/signin.ts
@@ -4,19 +4,21 @@ import config from '../../../config';
import { ILocalUser } from '../../../models/user';
export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
- const expires = 1000 * 60 * 60 * 24 * 365; // One Year
- ctx.cookies.set('i', user.token, {
- path: '/',
- domain: config.hostname,
- // SEE: https://github.com/koajs/koa/issues/974
- // When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
- secure: config.url.startsWith('https'),
- httpOnly: false,
- expires: new Date(Date.now() + expires),
- maxAge: expires
- });
-
if (redirect) {
+ //#region Cookie
+ const expires = 1000 * 60 * 60 * 24 * 365; // One Year
+ ctx.cookies.set('i', user.token, {
+ path: '/',
+ domain: config.hostname,
+ // SEE: https://github.com/koajs/koa/issues/974
+ // When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
+ secure: config.url.startsWith('https'),
+ httpOnly: false,
+ expires: new Date(Date.now() + expires),
+ maxAge: expires
+ });
+ //#endregion
+
ctx.redirect(config.url);
} else {
ctx.status = 204;