Pārlūkot izejas kodu

fix: valid password on reset-password page (#2753)

tags/0.5.9
yoogo pirms 1 gada
vecāks
revīzija
bd26c933d2
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 9
- 6
api/services/account_service.py Parādīt failu

from extensions.ext_redis import redis_client from extensions.ext_redis import redis_client
from libs.helper import get_remote_ip from libs.helper import get_remote_ip
from libs.passport import PassportService from libs.passport import PassportService
from libs.password import compare_password, hash_password
from libs.password import compare_password, hash_password, valid_password
from libs.rsa import generate_key_pair from libs.rsa import generate_key_pair
from models.account import * from models.account import *
from services.errors.account import ( from services.errors.account import (
account.current_tenant_id = available_ta.tenant_id account.current_tenant_id = available_ta.tenant_id
available_ta.current = True available_ta.current = True
db.session.commit() db.session.commit()
if datetime.utcnow() - account.last_active_at > timedelta(minutes=10): if datetime.utcnow() - account.last_active_at > timedelta(minutes=10):
account.last_active_at = datetime.utcnow() account.last_active_at = datetime.utcnow()
db.session.commit() db.session.commit()
if account.password and not compare_password(password, account.password, account.password_salt): if account.password and not compare_password(password, account.password, account.password_salt):
raise CurrentPasswordIncorrectError("Current password is incorrect.") raise CurrentPasswordIncorrectError("Current password is incorrect.")


# may be raised
valid_password(new_password)

# generate password salt # generate password salt
salt = secrets.token_bytes(16) salt = secrets.token_bytes(16)
base64_salt = base64.b64encode(salt).decode() base64_salt = base64.b64encode(salt).decode()


account.interface_language = interface_language account.interface_language = interface_language
account.interface_theme = interface_theme account.interface_theme = interface_theme
# Set timezone based on language # Set timezone based on language
account.timezone = language_timezone_mapping.get(interface_language, 'UTC')
account.timezone = language_timezone_mapping.get(interface_language, 'UTC')


db.session.add(account) db.session.add(account)
db.session.commit() db.session.commit()
tenant_account_join = TenantAccountJoin.query.filter_by(account_id=account.id, tenant_id=tenant_id).first() tenant_account_join = TenantAccountJoin.query.filter_by(account_id=account.id, tenant_id=tenant_id).first()
if not tenant_account_join: if not tenant_account_join:
raise AccountNotLinkTenantError("Tenant not found or account is not a member of the tenant.") raise AccountNotLinkTenantError("Tenant not found or account is not a member of the tenant.")
else:
else:
TenantAccountJoin.query.filter(TenantAccountJoin.account_id == account.id, TenantAccountJoin.tenant_id != tenant_id).update({'current': False}) TenantAccountJoin.query.filter(TenantAccountJoin.account_id == account.id, TenantAccountJoin.tenant_id != tenant_id).update({'current': False})
tenant_account_join.current = True tenant_account_join.current = True
# Set the current tenant for the account # Set the current tenant for the account
return account return account


@classmethod @classmethod
def invite_new_member(cls, tenant: Tenant, email: str, language: str, role: str = 'normal', inviter: Account = None) -> str:
def invite_new_member(cls, tenant: Tenant, email: str, language: str, role: str = 'normal', inviter: Account = None) -> str:
"""Invite new member""" """Invite new member"""
account = Account.query.filter_by(email=email).first() account = Account.query.filter_by(email=email).first()



+ 3
- 1
web/app/activate/activateForm.tsx Parādīt failu

showErrorMessage(t('login.error.passwordEmpty')) showErrorMessage(t('login.error.passwordEmpty'))
return false return false
} }
if (!validPassword.test(password))
if (!validPassword.test(password)) {
showErrorMessage(t('login.error.passwordInvalid')) showErrorMessage(t('login.error.passwordInvalid'))
return false
}


return true return true
}, [name, password, showErrorMessage, t]) }, [name, password, showErrorMessage, t])

+ 6
- 2
web/app/components/header/account-setting/account-page/index.tsx Parādīt failu

showErrorMessage(t('login.error.passwordEmpty')) showErrorMessage(t('login.error.passwordEmpty'))
return false return false
} }
if (!validPassword.test(password))
if (!validPassword.test(password)) {
showErrorMessage(t('login.error.passwordInvalid')) showErrorMessage(t('login.error.passwordInvalid'))
if (password !== confirmPassword)
return false
}
if (password !== confirmPassword) {
showErrorMessage(t('common.account.notEqual')) showErrorMessage(t('common.account.notEqual'))
return false
}


return true return true
} }

Notiek ielāde…
Atcelt
Saglabāt