Skip to content

Commit

Permalink
Improve user dependency docks
Browse files Browse the repository at this point in the history
  • Loading branch information
mekanix committed Nov 7, 2021
1 parent e5f9492 commit 5f2e0b3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ from typing import List

import ormar
from fastapi import HTTPException
from freenit.config import getConfig
from freenit.router import route

from ..models.blog import Blog, BlogOptional
Expand All @@ -66,7 +67,12 @@ class BlogListAPI():
return await Blog.objects.all()

@staticmethod
async def post(blog: Blog) -> Blog:
async def post(
blog: Blog,
user_data: auth.UserDB = Depends(current_user.active),
) -> Blog:
user = await auth.UserModel.objects.get(id=user_data.id)
blog.user = user
await blog.save()
return blog

Expand Down

0 comments on commit 5f2e0b3

Please sign in to comment.