mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-05 02:08:14 +09:00
Update signin.ts
This commit is contained in:
parent
bdef33e88d
commit
f257853906
@ -4,19 +4,21 @@ import config from '../../../config';
|
|||||||
import { ILocalUser } from '../../../models/user';
|
import { ILocalUser } from '../../../models/user';
|
||||||
|
|
||||||
export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
|
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) {
|
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);
|
ctx.redirect(config.url);
|
||||||
} else {
|
} else {
|
||||||
ctx.status = 204;
|
ctx.status = 204;
|
||||||
|
Loading…
Reference in New Issue
Block a user