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

Added /roles/ API endpoint #3311

Merged
merged 1 commit into from
Jul 21, 2014
Merged

Added /roles/ API endpoint #3311

merged 1 commit into from
Jul 21, 2014

Conversation

javorszky
Copy link
Contributor

Closes #3196

  • adds /roles/ endpoint, currently there are no other parameters to pass
  • gets the current user as context
  • filters available roles according to current user's roles' and only returns the ones that the current user would have permission to assign
  • if we're not signed in, gives a "please sign in" (standard) error
  • if we're signed in, but user is not in the context, gives a "there was no user in the context" error
  • if the user is an "Author", gives a "there are no available roles to assign" error

Caveats:

  • hacky implementation of the filter, at some point it should be solved with canThis
  • there are no tests
  • for some reason the setup functional test was failing for me locally

@javorszky
Copy link
Contributor Author

I'll put in tests once tests actually run again. Currently they fail on a tag after each hook, and then on a casperjs POST to /token/.

@javorszky
Copy link
Contributor Author

@ErisDS, wrapped the call in a canthis browse

@javorszky
Copy link
Contributor Author

Yup, the mysterious tag.aftereachmodel thing. Once that's solved I think I'll have to rebase and have the test run again. I'll look at those tomorrow.

Closes #3196

* adds `/roles/` endpoint
* is given the current user as context
* wraps everything in a canthis.browse.role
* gets all the available roles (should "Owner" be filtered out?)
* optional parameter: `permission=assign`. Gets all roles authenticated user could assign
* if we're not signed in, gives a "please sign in" (standard) error
* if we're signed in, but user is not in the context, gives a "there was no user in the context" error
* if the user is an "Author", gives a "there are no available roles to assign" error
* implemented hacky filter because when.js produces heisenbugs past 3.2.3 (when.filter not available)
* added extra fixtures to `permissions.json`. Might need a migration.

Caveats:

* there are no tests
* for some reason the setup functional test was failing for me locally
ErisDS added a commit that referenced this pull request Jul 21, 2014
@ErisDS ErisDS merged commit 0e16857 into TryGhost:master Jul 21, 2014
@javorszky javorszky deleted the iss3196 branch July 22, 2014 00:36
@jaswilli
Copy link
Contributor

filters available roles according to current user's roles' and only returns the ones that the current user would have permission to assign

@javorszky I know there aren't actual tests for this behavior, but did you confirm that this part of it was working?

I'm going through #3083 and when I make a call to /ghost/api/v0.1/roles/?permissions=assign I get no results back for any user other than the owner user (id: 1).

@javorszky
Copy link
Contributor Author

@jaswilli, hm... it should work. I'll test it though, and will write tests for this (hopefully it's going to be easy-ish)

Thanks for flagging it up!

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

Successfully merging this pull request may close these issues.

Add role endpoint
3 participants