some fixes for models

This commit is contained in:
2021-08-19 18:33:39 +03:00
parent 0cb0b85bce
commit 94518adcc5
10 changed files with 31 additions and 38 deletions

View File

@@ -25,12 +25,12 @@ class Identity:
def identity_oauth(input) -> User:
with local_session() as session:
user = session.query(OrmUser).filter(
or_(OrmUser.oauth_id == input["oauth_id"], OrmUser.email == input["email"])
or_(OrmUser.oauth == input["oauth"], OrmUser.email == input["email"])
).first()
if not user:
user = OrmUser.create(**input)
if not user.oauth_id:
user.oauth_id = input["oauth_id"]
if not user.oauth:
user.oauth = input["oauth"]
session.commit()
user = User(**user.dict())

View File

@@ -57,9 +57,9 @@ async def oauth_authorize(request):
token = await client.authorize_access_token(request)
resp = await client.get('user', token=token)
profile = resp.json()
oauth_id = profile["id"]
oauth = profile["id"]
user_input = {
"oauth_id" : oauth_id,
"oauth" : oauth,
"email" : profile["email"],
"username" : profile["name"]
}