Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow logout with invalid session #7278

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3860,6 +3860,28 @@ describe('Parse.User testing', () => {
});
});

it('can logout with expired session token', async () => {
await Parse.User.signUp('asdf', 'zxcv');
const sessionQuery = new Parse.Query(Parse.Session);
const session = await sessionQuery.first({ useMasterKey: true });
const database = Config.get(Parse.applicationId).database;
await database.update(
'_Session',
{ objectId: session.id },
{ expiresAt: new Date().setFullYear(2010) },
{}
);
await Parse.User.logOut();
});

it('can logout with invalid session token', async () => {
await Parse.User.signUp('asdf', 'zxcv');
const sessionQuery = new Parse.Query(Parse.Session);
const session = await sessionQuery.first({ useMasterKey: true });
await session.destroy({ useMasterKey: true });
await Parse.User.logOut();
});

it('does not duplicate session when logging in multiple times #3451', done => {
const user = new Parse.User();
user
Expand Down
5 changes: 4 additions & 1 deletion src/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ export function handleParseHeaders(req, res, next) {
return Promise.resolve()
.then(() => {
// handle the upgradeToRevocableSession path on it's own
if (req.url === '/logout') {
return Promise.resolve();
}
if (
info.sessionToken &&
req.url === '/upgradeToRevocableSession' &&
Expand All @@ -241,8 +244,8 @@ export function handleParseHeaders(req, res, next) {
.then(auth => {
if (auth) {
req.auth = auth;
next();
}
next();
})
.catch(error => {
if (error instanceof Parse.Error) {
Expand Down