chore: Use httpOnly authentication cookie (#5552)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import crypto from "crypto";
|
||||
import { addMinutes, subMinutes } from "date-fns";
|
||||
import { addHours, addMinutes, subMinutes } from "date-fns";
|
||||
import JWT from "jsonwebtoken";
|
||||
import { Context } from "koa";
|
||||
import { Transaction, QueryTypes, SaveOptions, Op } from "sequelize";
|
||||
@@ -453,6 +453,22 @@ class User extends ParanoidModel {
|
||||
this.jwtSecret
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns a session token that is used to make collaboration requests and is
|
||||
* stored in the client memory.
|
||||
*
|
||||
* @returns The session token
|
||||
*/
|
||||
getCollaborationToken = () =>
|
||||
JWT.sign(
|
||||
{
|
||||
id: this.id,
|
||||
expiresAt: addHours(new Date(), 24).toISOString(),
|
||||
type: "collaboration",
|
||||
},
|
||||
this.jwtSecret
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns a temporary token that is only used for transferring a session
|
||||
* between subdomains or domains. It has a short expiry and can only be used
|
||||
|
||||
Reference in New Issue
Block a user