(Closed) Insert Username in Collection with Accounts-ui

Here’s the relevant part of the Meteor docs:


The behavior of update differs depending on whether it is called by trusted or untrusted code. Trusted code includes server code and method code. Untrusted code includes client-side code such as event handlers and a browser’s JavaScript console.
Untrusted code can only modify a single document at once, specified by its _id. The modification is allowed only after checking any applicable allow and deny rules. The number of affected documents will be returned to the callback. Untrusted code cannot perform upserts, except in insecure mode.

But, yes, I could take a look at it.

And before I forget: DON’T publish the ServiceConfiguration to GitHub (or at least, replace the secret key)!

Alright. Just trying to upload in a minute

Client --> Front --> Frontpage.js

The ServiceConfiguration needs to live on the server. Not at the client.

Otherwise anyone would know your secret key and could impersonate your app at the corresponding service.

The reason you got this error message was due to the use of upsert which is not allowed on the client.

That makes sence. So where do i put the code? post.js under isServer?

No. You put it somewhere in the server folder.

I’ve put it in under publish.js. It gives me this error:

TypeError: Object [object Object] has no method 'loginWithFacebook’
at server/publish.js:27:8
at C:\Users\Jonas\Projects\Socialplatform.meteor\local\build\programs\server\app\server\publish.js:40:4
at C:\Users\Jonas\Projects\Socialplatform.meteor\local\build\programs\server\boot.js:242:10
at Array.forEach (native)
at Function.
.each..forEach (C:\Users\Jonas\AppData\Local.meteor\packages\meteor-tool\1.1.10\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
at C:\Users\Jonas\Projects\Socialplatform.meteor\local\build\programs\server\boot.js:137:5
Exited with code: 8
Your application is crashing. Waiting for file change.

You copied all of the code onto the server, didn’t you?


Yea i’m kind of a newbie to this… :confounded:

I’ve added the serviceconfirguration in the server folder and LogInWithFacebook on Frontpage. The app is running, but back at it with error:

Error: Unknown error

Did you register your app at the provider (i.e. Facebook) and got a valid secret key?

Yes i’ve added the clientId and secret in the ServiceConfiguration

And you do have Facebook in your configuration and not Weibo as shown at Github?

Yes i have. Still the same error.

When i run the debugger, it says err = S…n.ConfigError {message: “Login service configuration not yet loaded”

Please update the Github repo accordingly.

It’s updated now on github

Not seeing any changes.

their should be 2 folders with the commit: updated at client and server

I see the problem now. Here’s the thing:

By putting Meteor.loginWithFacebook() directly into the client code, you will always try to login as soon as the client code is executed (which means: You see the page, your client tries to login immediately).

You want to wrap this code into a click-handler which only logs in when you actually do something (like, click on a login-button).

If you want to be doubly sure that you don’t run into this error again, you’d also need to do this:

if(Accounts.loginServicesConfigured()) {
        requestPermissions: ['public_profile'] 
    }, function (err) { 
        if (err) 
            console.log("Error: " + (err.reason || 'Unknown error')); 
} else {
    console.log("Services not yet available. Try again later");