TryGhost/Ghost — pull request #3311 by javorszky (2014-07-17 12:41:08+00:00)
Title: Added /roles/ API endpoint

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