Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Check If Articles Policy Allows #533

Closed
AliceRossa opened this issue Apr 25, 2015 · 7 comments
Closed

Check If Articles Policy Allows #533

AliceRossa opened this issue Apr 25, 2015 · 7 comments
Assignees
Milestone

Comments

@AliceRossa
Copy link

Hello,

I am a beginner with AngularJS, I will wish that only admins can add, edit and delete articles.

I work on the branch 0.4.0 and I edited the articles.server.policy.js file like this:

roles: ['user'],
  allows: [{
    resources: '/api/articles',
    permissions: ['get', <del>'post'</del>]
} ...

User group can't post articles from api BUT can still see 'create article' view, how can I hide and redirect the user?

Something like this? But where do I put this code?

if ($scope.authentication.user.roles.indexOf('admin') > -1) $location.path('/');

Thank you very much for your help, greetings from France!

@ilanbiala
Copy link
Member

Please highlight your code blocks properly to make it easier for others to help.

@AliceRossa
Copy link
Author

Sorry I am new here , I just change my code blocks.
Do you have any idea to help me?

@ilanbiala
Copy link
Member

You need to add that to somewhere in the article module on the client side to prevent the user from accessing any of those pages. Maybe do a resolve in the states or something like that.

@anderskristo
Copy link

I would do like this:
In your controller, redirect to home if user isn't Admin.

if (!$scope.authentication.user.roles.indexOf('admin') $location.path('/');

In your view:

 data-ng-show="authentication.user"

or something like that?

@codydaig
Copy link
Member

@AliceRossa - We're you able to figure this out?

@mleanos
Copy link
Member

mleanos commented Aug 20, 2015

@AliceRossa perhaps this PR is something along the lines of what you need? #807

@lirantal lirantal added this to the 0.4.x milestone Aug 20, 2015
@codydaig
Copy link
Member

@AliceRossa I'm closing this issue for now. If it's still an issue, feel free to reopen.

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

No branches or pull requests

6 participants