parse-community / parse-community/parse-server
`linkWith` not returns a `sessionToken` in CloudCloud
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
I'm encountering an issue with linkWith in Cloud Code on Parse-Server 7.2. When linking a user with a third-party provider, the method does not return a sessionToken as expected. This breaks the intended behavior, where the user should be logged in automatically after linking.
Steps to Reproduce
Here is the code snippet that demonstrates the issue:
Parse.Cloud.define(
'auth',
async req => {
const { authData, nickname, email } = req.params;
const authName = Object.keys(authData)[0];
if (!authName) {
throw new Parse.Error(1000, {
code: 1001,
msg: 'invalid authData',
});
}
const provider = getAuthProvider(authName, authData?.[authName]);
if (!provider) {
throw new Parse.Error(1000, {
code: 1001,
msg: 'invalid authData',
});
}
let hasUser;
if (email) {
const query = new Parse.Query(Parse.User);
query.equalTo('email', email);
hasUser = await query.first({ useMasterKey: true });
req.log.info('hasUser', hasUser);
}
const user = new Parse.User();
if (!hasUser) {
user.set('email', email);
user.set('nickname', nickname);
}
return user.linkWith(provider, authData?.[authName]);
},
{
fields: {
authData: {
required: true,
type: Object,
},
nickname: {
required: true,
type: String,
},
email: {
type: String,
options: email => {
return /^[\w-\.]+@([\w-]+\.)+[\w-]{2,12}$/.test(email);
},
},
},
}
);
Attempt to link the user with a provider using linkWith.
Observe that no sessionToken is returned.
Environment
Parse Server Version: 7.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied Cloud Code example on Parse Server 7.2 and tracing the linkWith authentication flow. Confirm the expected sessionToken behavior and add or update regression coverage so the reproduced linking case either returns the token or clearly reports the intended result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100