mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Merge pull request #267 from HeyPuter/eric/session-fixes
session management fixes
This commit is contained in:
commit
eb96dd952b
@ -63,8 +63,10 @@ const auth2 = async (req, res, next) => {
|
||||
|
||||
if(!token) {
|
||||
APIError.create('token_missing').write(res);
|
||||
return;
|
||||
} else if (typeof token !== 'string') {
|
||||
APIError.create('token_auth_failed').write(res);
|
||||
return;
|
||||
} else {
|
||||
token = token.replace('Bearer ', '')
|
||||
}
|
||||
|
@ -71,6 +71,11 @@ module.exports = eggspress(['/signup'], {
|
||||
const { user, token } = await svc_auth.check_session(
|
||||
req.cookies[config.cookie_name]
|
||||
);
|
||||
res.cookie(config.cookie_name, token, {
|
||||
sameSite: 'none',
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
});
|
||||
// const decoded = await jwt.verify(token, config.jwt_secret);
|
||||
// const user = await get_user({ uuid: decoded.uuid });
|
||||
if ( user ) {
|
||||
|
@ -240,7 +240,10 @@ class AuthService extends BaseService {
|
||||
[uuid],
|
||||
);
|
||||
|
||||
session.meta = JSON.parse(session.meta ?? {});
|
||||
session.meta = this.db.case({
|
||||
mysql: () => session.meta,
|
||||
otherwise: () => JSON.parse(session.meta ?? "{}")
|
||||
})();
|
||||
|
||||
return session;
|
||||
}
|
||||
@ -375,10 +378,13 @@ class AuthService extends BaseService {
|
||||
);
|
||||
|
||||
sessions.forEach(session => {
|
||||
session.meta = this.db.case({
|
||||
mysql: () => session.meta,
|
||||
otherwise: () => JSON.parse(session.meta ?? "{}")
|
||||
})();
|
||||
if ( session.uuid === actor.type.session ) {
|
||||
session.current = true;
|
||||
}
|
||||
session.meta = JSON.parse(session.meta ?? {});
|
||||
});
|
||||
|
||||
return sessions;
|
||||
|
@ -87,6 +87,7 @@ const UIWindowManageSessions = async function UIWindowManageSessions () {
|
||||
const resp = await fetch(`${api_origin}/auth/revoke-session`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Bearer ${puter.authToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
@ -115,6 +116,9 @@ const UIWindowManageSessions = async function UIWindowManageSessions () {
|
||||
|
||||
const reload_sessions = async () => {
|
||||
const resp = await fetch(`${api_origin}/auth/list-sessions`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${puter.authToken}`,
|
||||
},
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user