users can only view their own gallery

This commit is contained in:
iou1name 2020-02-26 07:15:09 -05:00
parent 7dafe683dd
commit 0ff04ae58a
2 changed files with 3 additions and 6 deletions

View File

@ -83,13 +83,10 @@ async def index(request):
return web.json_response(urls) return web.json_response(urls)
@routes.get('/gallery/{user_id}', name='gallery') @routes.get('/gallery', name='gallery')
async def gallery(request): async def gallery(request):
"""A user's gallery page.""" """A user's gallery page."""
try: user_id = int(request.cookies.get('userid'))
user_id = int(request.match_info['user_id'])
except ValueError:
raise web.HTTPNotFound
async with request.app['pool'].acquire() as conn: async with request.app['pool'].acquire() as conn:
uploads = await conn.fetch( uploads = await conn.fetch(

View File

@ -4,5 +4,5 @@
</div> </div>
<nav> <nav>
<span><a href="{{ url('index') }}">Home</a></span> <span><a href="{{ url('index') }}">Home</a></span>
<span><a href="{{ url('gallery', user_id=request.cookies.get('userid')) }}">Gallery</a></span> <span><a href="{{ url('gallery') }}">Gallery</a></span>
</nav> </nav>