Skip to content

Commit

Permalink
added migration for token auth
Browse files Browse the repository at this point in the history
  • Loading branch information
dantownsend committed Nov 18, 2019
1 parent 6c85286 commit 6d00e27
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions piccolo_api/token_auth/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ async def get_token(self, username: str, password: str) -> t.Optional[str]:
await TokenAuth.select(TokenAuth.token)
.first()
.where(TokenAuth.user == user)
.run()
)
return None

Expand Down
22 changes: 22 additions & 0 deletions piccolo_api/token_auth/migrations/2019-11-18T22:24:41.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from piccolo.table import Table
from piccolo.columns import Varchar, ForeignKey


ID = "2019-11-18T22:24:41"


class BaseUser(Table, tablename="piccolo_user"):
pass


class TokenAuth(Table):
token = Varchar()
user = ForeignKey(references=BaseUser)


async def forwards():
await TokenAuth.create().run()


async def backwards():
await TokenAuth.alter().drop_table().run()
Empty file.
4 changes: 4 additions & 0 deletions piccolo_api/token_auth/migrations/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME = "token_auth"


DEPENDENCIES = ["piccolo.extensions.user.migrations.config"]

0 comments on commit 6d00e27

Please sign in to comment.