I am using Autoform and Collection2 package in meteor. I am trying to store current logged in userId with inserted data. What is the right way to do that??

```
// both/collections/myCollection.js

MyCollection = new Mongo.Collection("mycollection");

MyCollection.attachSchema(new SimpleSchema({
    fname : {
        type: String,
        label: "First Name"
    },
    lname : {
        type: String,
        label: "Last Name",
    }
}));

MyCollection.allow({
    insert: function(userId, doc){
        return doc && doc.userId === userId;
    },
    update: function(userId, doc){
        return doc && doc.userId === userId;
    }
})

```

myTemplate.html

```
// client/myTemplate.html

<template name="myTemplate">
    {{> quickForm collection="MyCollection" id="insertMyData" type="insert"}}
</template>

```

myTemplate.js

```
// client/myTemplate.js

Template.myTemplate.created = function(){

    var postHooks = {
        before: {
            insert: function(doc) {
                if(Meteor.userId()){
                    doc.userId = Meteor.userId();
                }
                return doc;
            }
        }
    }
 AutoForm.addHooks('insertMyData', postHooks);
 }

```

I remove the insecure package and tried with Writing Data With Allow/Deny ([link](https://www.discovermeteor.com/blog/meteor-and-security/)) but now i am getting error like:

```
Meteor.makeErrorType.errorClass {error: 403, reason: "Access denied", details: undefined, message: "Access denied [403]", errorType: "Meteor.Error"…} 

```

Normally Autoform storing data like :

```
{
    "_id" : "r4uskTttNzADnhZjN",
    "fname" : "firstName",
    "lname" : "lastName"
}

```

I wanted to store like :

```
{
    "_id" : "r4uskTttNzADnhZjN",
    "fname" : "firstName",
    "lname" : "lastName"
    "currentUser" : "lsgNynHDrM4Dv9wpH"
}

```