Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'userCanSeeProfile.js' redirect kinda limited... #10

Closed
stevenrace opened this issue Jan 12, 2014 · 1 comment
Closed

'userCanSeeProfile.js' redirect kinda limited... #10

stevenrace opened this issue Jan 12, 2014 · 1 comment

Comments

@stevenrace
Copy link

While low priority, I'd like some help wrapping my head around this.

In /config/policies , 'UserCanSeeProfile is being called when accessing the User model. This works when accessing localhost:1337/user - we get redirected to /session/new to login. But if one accesses /user/show (or /edit/ /update) - a type error is thrown.

      500: TypeError: Cannot read property 'id' of undefined
@Foxandxss
Copy link

If there is no user on the session (AKA logged in) that error will show.

A guard should work, like:

if (!req.session.User) return;

at the top of the policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants