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:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user