Skip to content

feat: Allow Parse.Session.current on expired session token instead of throwing error #8722

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

Merged
merged 3 commits into from
Dec 25, 2023
Merged
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
29 changes: 29 additions & 0 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3224,6 +3224,35 @@ describe('Parse.User testing', () => {
.catch(done.fail);
});

it('should return current session with expired expiration date', async () => {
await Parse.User.signUp('buser', 'somepass', null);
const response = await request({
method: 'GET',
url: 'http://localhost:8378/1/classes/_Session',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
});
const body = response.data;
const id = body.results[0].objectId;
const expiresAt = new Date(new Date().setYear(2015));
await request({
method: 'PUT',
url: 'http://localhost:8378/1/classes/_Session/' + id,
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
'Content-Type': 'application/json',
},
body: {
expiresAt: { __type: 'Date', iso: expiresAt.toISOString() },
},
});
const session = await Parse.Session.current();
expect(session.get('expiresAt')).toEqual(expiresAt);
});

it('should not create extraneous session tokens', done => {
const config = Config.get(Parse.applicationId);
config.database
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ const handleRateLimit = async (req, res, next) => {
export const handleParseSession = async (req, res, next) => {
try {
const info = req.info;
if (req.auth) {
if (req.auth || req.url === '/sessions/me') {
next();
return;
}
Expand Down