wip
This commit is contained in:
@ -1,19 +1,20 @@
|
||||
import config from '../../../config';
|
||||
import * as Koa from 'koa';
|
||||
|
||||
export default function(res, user, redirect: boolean) {
|
||||
import config from '../../../config';
|
||||
import { ILocalUser } from '../../../models/user';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user