-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Login and CreateUser method send back the added message without fully fields #13116
Comments
accounts-password@2.4.0 |
Without reproduction, it is hard to point something out. But you could try some things. In Meteor, the DDP messages synchronize the client and server data. The sequence and content of these messages are crucial for maintaining data consistency. The issue you're facing may arise from the timing and completeness of the One thing you can try is to ensure that the // Server-side code
Meteor.publish(null, function() {
if (this.userId) {
return Meteor.users.find(
{ _id: this.userId },
{
fields: {
emails: 1,
createdAt: 1,
language: 1,
timezone: 1,
sortedRecurringIds: 1,
dark: 1,
// Add other fields as needed
}
}
);
} else {
this.ready();
}
}); If this doesn't work, you can handle the incomplete data on the client by waiting for the // Client-side code
const userSubscription = Meteor.subscribe('userData');
Tracker.autorun(() => {
if (userSubscription.ready()) {
const user = Meteor.user();
if (user) {
// Check if the user data is complete
if (user.createdAt && user.language && user.timezone) {
// Proceed with complete user data
console.log('User data is complete:', user);
} else {
// Wait for the changed message to complete the data
console.log('User data is incomplete, waiting for updates...');
}
}
}
}); Could you try these and tell me if they work? |
Hello, I'm glad to tell you, your advice is work. When I try the auto publish in server, the client will receive added message with total fields about user. |
If added messag received after than 'result' ddp message when call login method, it will be a more nice thing. |
Meteor 2.15.
accounts-base@2.2.10
When I call the Login or CreateUser method in client, the client will receive a added ddp message, whose fields is not fully:
{"msg":"added","collection":"users","id":"jD2HdzpSDQXmM4fBK","fields":{"emails":[{"address":"789@qq.com","verified":false}]}}
If client subscribe user after login, the client will receive a changed message after this added message:
{"msg":"changed","collection":"users","id":"jD2HdzpSDQXmM4fBK","fields":{"createdAt":1712734497,"language":"zh","timezone":"CST","sortedRecurringIds":["j9M34LZmPL73m9nCH","AJ5zsM5MY3Fxt7r3m","wAySnvQiwJhpWj88v","uNEgTsagsNfyYqHKJ","uWSzGyFQ4NifTJerr","WER4nWaA679twZEgQ","bTgJxfHKEAgeZEm9r","tvDrSJCxLiPJisH2p","LeZgrrmy2KqJrRrGc","eGzPhmr9CyfgZnL9i","kxZGapM4wspDQqncL","6Dzwwe6PqpLXA9WWT","aY9Du4xRSvrLjEdWr","7DHKWmzRwAH7QkTKJ","nWBnwWfct4ArL9jY3","vG5bLyba2hBw8CbAh","P4byKi973xbLR8BBv","tRz2Aiz6KRa85aZC2","REWGqGnEjASCv6Wy9","bCxXYJzb9EGKx49uk"],"dark":false}}
Now, this question very trouble me. The client will put the data from added message into client database, then change this data according to changed message. So, the added message without fully fields will result in error data.
I expect this added message contain all fields, or there is no added message caused from Login and CreateUser method.
By the way, this added message sometimes received before than 'result' and 'update' ddp message:
{"msg":"connected","session":"e88doLkqWghXmaMnh"} {"msg":"added","collection":"users","id":"jD2HdzpSDQXmM4fBK","fields":{"emails":[{"address":"789@qq.com","verified":false}]}} {"msg":"updated","methods":["login-3"]} {"msg":"result","id":"login-3","result":{"id":"jD2HdzpSDQXmM4fBK","token":"xdC94BG4tATu_Pq6b4HXc2YHktNYg-fjCURyGjTMEha","tokenExpires":{"$date":2029738253256},"type":"resume"}}
My call method code as below:
1.signin-login
call( methodNameLogin, args: <dynamic>[ <String, dynamic>{ keyUser: <String, String>{keyEmail: _email}, keyPassword: <String, dynamic>{ keyDigest: sha256.convert(utf8.encode(_password)).toString(), keyAlgorithm: keySha256, }, } ], )
2.signin-createuser
call( methodNameCreateUser, args: <dynamic>[ <String, dynamic>{ keyEmail: _email, keyPassword: _password, keyTimezone: timezone, keyLanguage: language, keyDark: dark, } ], )
3.resume-login
if (_loginTokenInfo != null) { final String loginToken = _loginTokenInfo!.value; final String loginWithTokenMessage = json.encode(<String, dynamic>{ keyMSG: keyMethod, keyMethod: keyLogin, keyParams: <dynamic>[ <String, String>{keyResume: loginToken} ], keyId: '$keyLogin-$_idCounter', }); _socket!.sink.add(loginWithTokenMessage); }
The text was updated successfully, but these errors were encountered: