question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this.userId or this.user() is always null in protected function

See original GitHub issue

Hello, I would like to protect the files from being accessible by a non-connected user. At the moment anyone can do : http://my-app.com/cdn/storage/Files/fileId/original/fileId.pdf and the file is presented to the browser (even if the user is not connected)

I have implemented :

configServer["protected"] = function(fileObj){
    console.log("protected > this.userId : ", this.userId); //This returns always null
    if (this.userId){return true;}
    return false
  }

But this.userId or this.user() always return null.

I am using v 1.11.2. with Meteor 1.8.1

I am both :

Is this a normal behavior ? I have seen some discussion about taking the userId from cookies. Do I have to activate/set cookies somewhere before in my app or MeteorFiles is doing it ? Thanks

Similar issues :

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
dokithononcommented, Dec 24, 2019

Hello, We did together place account-base above ostrio:files in the meteor/package files. But I had other sub packages that were using ostrio:files like this : api.use(['ostrio:files]) and these packages did not have account-base declared above. I have replaced by api.use(['account-base', 'ostrio:files']) and it seems to work. I will try and make tests beginning of january and let you know. Thanks and have a nice Christmas.

1reaction
dokithononcommented, Jan 6, 2020

Yes. account-base should be before ostrio:files also in subpackages. Thanks for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auth::user() returns null - php - Stack Overflow
I faced a situation where Auth::user() always returns null , it was because I was trying to get the User in a controller's...
Read more >
Auth::user always returning null · Issue #30402 - GitHub
Here is my controller code. After trying different methods found around the web nothing seems to work! | is assigned the "api" middleware...
Read more >
Auth::user() returns null value - Laracasts
I'm working on username authentication. I thought my LoginController is working perfectly.But when i go to the page and do login.The page will...
Read more >
Authentication - Laravel - The PHP Framework For Web Artisans
When the auth middleware detects an unauthorized user, it will either return a JSON 401 response, or, if the request was not an...
Read more >
Magic Methods - Manual - PHP
If the method doesn't return anything then null is serialized and E_NOTICE is issued. Note: It is not possible for __sleep() to return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found