detroitledger / gnl_profile

API & data management system for the Detroit Ledger
https://www.detroitledger.org
0 stars 2 forks source link

Add an endpoint with current user info #152

Open hampelm opened 8 years ago

hampelm commented 8 years ago

It would be nice to have edit buttons on the front end when we're logged in

I haven't been able to find a way to do it with just the front end. I tried to make a test request to data.detroitledger.org/admin/content -- if it redirected, I'd know I can't log in. However, it rightly doesn't have CORS headers, so ajax isn't playing nice.

A simple solution would be a new API endpoint that returns current user info if you're logged in.

bnchdrff commented 8 years ago

i'll work on this tonight!

bnchdrff commented 8 years ago

try out https://data.detroitledger.org/api/1.0/userroles -- i've got branch https://github.com/detroitledger/gnl_profile/tree/userendpoint running on the server

bnchdrff commented 8 years ago

i guess the trick would be providing a jsonp response though?

bnchdrff commented 8 years ago

https://data.detroitledger.org/api/1.0/userroles?cb=foo for jsonp

hampelm commented 8 years ago

Nice! Thank you!

Looks like it'd be straightforward, so I'd suggest serving it from /api/1.0/user.jsonp as

{
   name: "matt",
   id: 123,
   roles:  ...
}

That way we can potentially do more with it in the future.