Skip to content

Commit

Permalink
Merge pull request #351 from DNO-inc/improve_auth_logs
Browse files Browse the repository at this point in the history
assign a `global' faculty if it is not present in db
  • Loading branch information
m-o-d-e-r authored May 29, 2024
2 parents 3fae828 + 1ba8e67 commit b3e1c84
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions burrito/utils/users_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,32 @@ def create_user_with_cabinet(

tmp_user_login = transliterate(f"{firstname} {cabinet_id}")

try:
user: Users = Users.create(
cabinet_id=cabinet_id,
firstname=firstname,
lastname=lastname,
login=tmp_user_login,
faculty=faculty,
group=group,
email=email,
role=role_object
)
return user

except Exception as e:
get_logger().error(e)
get_logger().warning(
f"""
Email {email}
Login {tmp_user_login}
Faculty {faculty}
Group {group}
"""
)
#TODO: tmp solution, i hope. Assign a `global' faculty to the user if it fails to create
for i in range(2):
try:
user: Users = Users.create(
cabinet_id=cabinet_id,
firstname=firstname,
lastname=lastname,
login=tmp_user_login,
faculty=faculty if not i else 1,
group=group,
email=email,
role=role_object
)
return user

except Exception as e:
get_logger().error(e)
get_logger().warning(
f"""
Email {email}
Login {tmp_user_login}
Faculty {faculty}
Group {group}
"""
)


def get_user_by_login(login: str) -> Users | None:
Expand Down

0 comments on commit b3e1c84

Please sign in to comment.