How to build a user login and commenting(with a reply) in meteor


#1

wthout using packeges.

I see all the tutorials are using these accounts packeges, which has a default functiinality i dislike.(no annomous logins)

I’m looking for a way to do this manually.(inclduing a fb login)

IS there any tutorial out there is right for me?


#2

Accounts package is not related to the way you build your app. Its about security and authenication methods.
Actually if you try to write any method you will notice that it doesn’t check anything, I mean… at all.

So once you declare a method you may get something like:

‘addComment’: function(msg,replyTo) {
//make sure to check params

var user = this.userId || ‘anonymous’;

Comments.insert({
comment: ‘msg’, //message
user: user // ‘anonymous’ if user isn’t logged in overwise his id
replied: replyTo //object containing a replied post and/or author, null if unset
});}

If you wanted to only allow authorized users to leave comments, you had to set it excplitly.

…someMethod() {
If (!this.userId) {throw new Meteor.Error(‘Unauthorized’);
… some code
}

BTW there are packages that expand basic accounts functionality up to roles support or unauthorized user support. But i suppose its not exactly what you wanted to do.


#3

I dont quite understand.

in my html ffile there is this code:
{{#if currentUser}}
{{> form}}
how o i by pass it with what you gave for annom user?

how do i define the replyTo object?