mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 07:19:25 -05:00
Add /api/me resource to fetch user info + modhash.
This commit is contained in:
committed by
Neil Williams
parent
d8348f6c87
commit
2b3b0616c1
@@ -137,6 +137,14 @@ class ApiController(RedditController):
|
||||
listing = wrap_links(filter(None, links or []), num = count)
|
||||
return BoringPage(_("API"), content = listing).render()
|
||||
|
||||
|
||||
@json_validate()
|
||||
def GET_me(self):
|
||||
if c.user_is_loggedin:
|
||||
return Wrapped(c.user).render()
|
||||
else:
|
||||
return {}
|
||||
|
||||
@validatedForm(VCaptcha(),
|
||||
name=VRequired('name', errors.NO_NAME),
|
||||
email=ValidEmails('email', num = 1),
|
||||
|
||||
@@ -219,6 +219,12 @@ class AccountJsonTemplate(ThingJsonTemplate):
|
||||
return bool(Subreddit.reverse_moderator_ids(thing))
|
||||
return ThingJsonTemplate.thing_attr(self, thing, attr)
|
||||
|
||||
def raw_data(self, thing):
|
||||
data = ThingJsonTemplate.raw_data(self, thing)
|
||||
if c.user_is_loggedin and thing._id == c.user._id:
|
||||
data["modhash"] = c.modhash
|
||||
return data
|
||||
|
||||
class LinkJsonTemplate(ThingJsonTemplate):
|
||||
_data_attrs_ = ThingJsonTemplate.data_attrs(ups = "upvotes",
|
||||
downs = "downvotes",
|
||||
|
||||
Reference in New Issue
Block a user