fix(directAccess/cloud-code): Pass installationId with LogIn (#6903)

InstallationId didn't get passed correctly. Resulting in _Session without installationId

https://github.com/parse-community/parse-server/blob/master/src/Routers/UsersRouter.js#L263

* Fixed error with POST /login and req.query is undefined
This commit is contained in:
Diamond Lewis
2020-09-17 11:53:02 -05:00
committed by GitHub
parent 90f396b09c
commit 1246c90e91
3 changed files with 34 additions and 2 deletions

View File

@@ -662,4 +662,35 @@ describe('ParseServerRESTController', () => {
}
);
});
it('ensures logIn is saved with installationId', async () => {
const installationId = 'installation123';
const user = await RESTController.request(
'POST',
'/classes/_User',
{ username: 'hello', password: 'world' },
{ installationId }
);
expect(user.sessionToken).not.toBeUndefined();
const query = new Parse.Query('_Session');
let sessions = await query.find({ useMasterKey: true });
expect(sessions.length).toBe(1);
expect(sessions[0].get('installationId')).toBe(installationId);
expect(sessions[0].get('sessionToken')).toBe(user.sessionToken);
const loggedUser = await RESTController.request(
'POST',
'/login',
{ username: 'hello', password: 'world' },
{ installationId }
);
expect(loggedUser.sessionToken).not.toBeUndefined();
sessions = await query.find({ useMasterKey: true });
// Should clean up old sessions with this installationId
expect(sessions.length).toBe(1);
expect(sessions[0].get('installationId')).toBe(installationId);
expect(sessions[0].get('sessionToken')).toBe(loggedUser.sessionToken);
});
});