Skip to content

Commit

Permalink
Fix for authlib backend
Browse files Browse the repository at this point in the history
Hopefully this will work

Signed-off-by: Michal Konecny <[email protected]>
  • Loading branch information
Zlopez committed Dec 5, 2024
1 parent 9a1cf97 commit eba218a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions anitya/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ def auth(name): # pragma: no cover
token = client.authorize_access_token()
if name == "fedora":
user_info = client.userinfo(token=token)
user_info["email"] = client.get("email", token=token)
user_info["email"] = token.get("email")
user_info["username"] = user_info["preferred_username"]
elif name == "github":
user_info = token.get("user", token=token)
resp = client.get("user", token=token)
user_info = resp.json()
elif name == "google":
user_info = token.get("userinfo")
user_info["username"] = user_info["email"]
else:
user_info = token.get("userinfo")
if not user_info:
Expand All @@ -63,9 +68,7 @@ def auth(name): # pragma: no cover
# Check if the user exists
user = User.query.filter(User.email == user_info["email"]).first()
if not user:
new_user = User(
email=user_info["email"], username=user_info["preferred_username"]
)
new_user = User(email=user_info["email"], username=user_info["username"])
Session.add(new_user)
Session.commit()
user = new_user
Expand Down

0 comments on commit eba218a

Please sign in to comment.