Hey @copleykj,
I saw your socialize meteor packages and I definitely want to start using them and contribute. Any chance you can get my started on using the socialize-profiles package?
Hey @copleykj,
I saw your socialize meteor packages and I definitely want to start using them and contribute. Any chance you can get my started on using the socialize-profiles package?
Sure, so right now the profile package is basically just a starting point for you to build on. The Idea is to get away from the profile key on the user document as itās easy to leave a large security hole in your app.
To get started you can append to the schema in a shared space file.
Profile.appendSchema({
firstName:{
type: String,
max: 20,
optional: true
},
lastName:{
type: String,
max: 25,
optional: true
}
});
And then you can add methods to the model like so
Profile.methods({
fullName: function(){
return this.firstName +" "+this.lastName;
}
});
As a note, you may need to run a package update as I just added the .methods()
function to the BaseModel object in a release about 30 minutes ago.
So this all makes sense to me. What I donāt understand: Your package automatically includes, when installed, the creation of the users profile?
Iām new to Meteor, so bare with me
All of the examples Iāve done so far, itās all about creating a āpostā or submitting an āarticleā which all can be created multiple times by the user. This is the first thing in meteor that Iāve had to deal with an object that is NOT created by the user, only one profile can exist per user, but they have control over the customization.
Yes, a new profile record is created on behalf of the user when a new user record is inserted. You can then customize the schema and create a way for the user to update their profile. This makes sense to me, but if there is enough feedback that this is any issue for others I can remove the automatic profile creation.
How would profile picture, I guess images work? Are they of type string and I just need to figure out the code to upload the photo?
Iām working on more packages, one of which would handle this situation, but until then my personal preference is to use cloudinary to upload the image and then store the ID returned from cloudinary and use their API via URL to request the image in the size I need with any adjustments already made to it. This is likely what the package I create will do as well.
I know this is how you would link to a post:
Router.route('/posts/:_id', { name: 'postPage' });
How do I access the path for the users profile?
This is what I have so far
Router.route('/:_id.profile.userName', { name: 'profile' });
I want to make the url be the userās userName.
This should get you startedā¦
Router.route('/:username', {
name: 'profile',
data: function() {
return Meteor.profiles.findOne({username:this.params.username);
},
subscriptions: function() {
return Meteor.subscribe("profileFor", this.params.username);
}
});
Ug, I think Iām in too deep with what I want to make. This doesnāt seem to be working.
Iāve done two Meteor tutorial books, Discover Meteor and My First Meteor Application. Both were a bit of a challenge to complete, with not a complete understanding of everything that I coded following along. I may not be ready to be using your awesome package yet.
Which part are you having trouble with?
Well I have a lot of the concepts scrambled up in my brain. Routing, templates, and helpers are what I feel good about. But Iām not quite sure what Iām missing. I keep Googling tons of different tutorials and try to mesh the tutorial code with my own project, but that just makes things worst because everyone has a different way on how they structure the files on their app.
Well if you have a code repo I can clone and you can point me to specific parts you are having trouble with, I can help. For now though Iām off to sleep. Iāll be back around in about 9 hours
Okay I think Iām getting somewhere.
I believe I implemented all the code properly, but now Iām getting an error the the command line
I20150612-21:58:30.227(-7)? Exception while invoking method 'ATCreateUserServer' TypeError: Cannot read property 'username' of null
I20150612-21:58:30.228(-7)? at Object.Profile.appendSchema.username.autoValue (packages/socialize:user-profile/common/profile-model.js:28:1)
Does that have to do with your package?
Okay. When I restart the data, make a new account, the app gives me that error. When I restart the server I can log in with the account I just created. But no profiles are created.
Meteor.profiles.find().count();
0
I need to subscribe to the profiles correct?
Ok, should be fixed now.
From an API design point of view, Iād suggest using a route more like:
Router.route('/profile/:username'...)
Otherwise, if you have a user with a username that is a key in your API space, youāll have issues. For example, if someone has the username āhomeā, or āpostā, your routes are suddenly ambiguous.
Hi. I have standard meteor app with installed accounts-ui accounts-password accounts-google and socialize:user-profile
In my main.js I added
Profile.appendSchema({ "firstName":{ type:String, required: true }, "lastName":{ type:String, required: true } })
now when register a user in my mondodb I have profiles collection but without firstName and lastName fieldsā¦ what should I do to get them?
Hello Kelly Copley, is there a tutorial on your profile package? I would love to take an online course or something about it.
A video going thru it would be really nice
There currently is not, but Iāve recently been acquiring the equipment necessary to do this, and thereās chance that it could be coming with content Iām looking to create as part of my Meteor Ambassadorship. Kids go back to school in couple of weeks so stay tuned.