How can I store login username as a variable using Meteor? -
how can make variable current user's username log in create database document them store info?
you need setup custom function configure user creation in server side, see accounts.oncreateuser on docs.meteor.com
in function can initialize user database document, either in user.field or user.profile.field. username automatically stored in user.username, not need create it.
then modify user record client side, call server method update meteor.users collection, ie
server/users.js
meteor.methods({ updateuser:function(fields){ if(!this.userid){ // error : no user logged in } check(fields,{/* fields verification */}); meteor.users.update(this.userid,{ $set:fields }); } }); client/main.js
meteor.call("updateuser",{ "username":"foo", "profile.bar":"bar" }); note meteor built-in user accounts simplify process : documented encourage re-read particular section in docs.
Comments
Post a Comment