mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
feat: Store accessToken in cookies instead of localStorage
This commit is contained in:
parent
cad3233da7
commit
7ef55ec578
27 changed files with 137 additions and 114 deletions
|
@ -34,11 +34,16 @@ module.exports = function defineCurrentUserHook(sails) {
|
|||
before: {
|
||||
'/*': {
|
||||
async fn(req, res, next) {
|
||||
const { authorization: authorizationHeader } = req.headers;
|
||||
|
||||
if (authorizationHeader && TOKEN_PATTERN.test(authorizationHeader)) {
|
||||
const accessToken = authorizationHeader.replace(TOKEN_PATTERN, '');
|
||||
let accessToken;
|
||||
if (req.headers.authorization) {
|
||||
if (TOKEN_PATTERN.test(req.headers.authorization)) {
|
||||
accessToken = req.headers.authorization.replace(TOKEN_PATTERN, '');
|
||||
}
|
||||
} else if (req.cookies.accessToken) {
|
||||
accessToken = req.cookies.accessToken;
|
||||
}
|
||||
|
||||
if (accessToken) {
|
||||
req.currentUser = await getUser(accessToken);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports.security = {
|
|||
allRoutes: true,
|
||||
allowOrigins: ['http://localhost:3000'],
|
||||
allowRequestHeaders: ['Authorization'],
|
||||
allowCredentials: false,
|
||||
allowCredentials: true,
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue