Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
chore: lint
  • Loading branch information
ZhouhaoJiang committed Sep 29, 2024
1 parent 86b182f commit d481a1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/controllers/console/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def post(self):
invitation = args["invite_token"]
if invitation:
invitation = RegisterService.get_invitation_if_token_valid(None, args["email"], invitation)

try:
if invitation:
data = invitation.get("data", {})
Expand Down
5 changes: 2 additions & 3 deletions api/services/account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def authenticate(email: str, password: str, invite_token: str = None) -> Account

if account.status in {AccountStatus.BANNED.value, AccountStatus.CLOSED.value}:
raise AccountLoginError("Account is banned or closed.")

if password and invite_token:
# if invite_token is valid, set password and password_salt
salt = secrets.token_bytes(16)
Expand All @@ -111,15 +111,14 @@ def authenticate(email: str, password: str, invite_token: str = None) -> Account
base64_password_hashed = base64.b64encode(password_hashed).decode()
account.password = base64_password_hashed
account.password_salt = base64_salt


if account.password is None or not compare_password(password, account.password, account.password_salt):
raise AccountPasswordError("Invalid email or password.")

if account.status == AccountStatus.PENDING.value:
account.status = AccountStatus.ACTIVE.value
account.initialized_at = datetime.now(timezone.utc).replace(tzinfo=None)

db.session.commit()

return account
Expand Down

0 comments on commit d481a1b

Please sign in to comment.