Update signin.ts

This commit is contained in:
syuilo 2018-11-28 05:27:34 +09:00
parent bdef33e88d
commit f257853906
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -4,6 +4,8 @@ import config from '../../../config';
import { ILocalUser } from '../../../models/user';
export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
if (redirect) {
//#region Cookie
const expires = 1000 * 60 * 60 * 24 * 365; // One Year
ctx.cookies.set('i', user.token, {
path: '/',
@ -15,8 +17,8 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
expires: new Date(Date.now() + expires),
maxAge: expires
});
//#endregion
if (redirect) {
ctx.redirect(config.url);
} else {
ctx.status = 204;