@@ -273,7 +273,7 @@ async def get_user_by_email(self, email: str) -> Optional[EmailUser]:
273273 logger .error (f"Error getting user by email { email } : { e } " )
274274 return None
275275
276- async def create_user (self , email : str , password : str , full_name : Optional [str ] = None , is_admin : bool = False , auth_provider : str = "local" ) -> EmailUser :
276+ async def create_user (self , email : str , password : str , full_name : Optional [str ] = None , is_admin : bool = False , auth_provider : str = "local" , skip_password_validation : bool = False ) -> EmailUser :
277277 """Create a new user with email authentication.
278278
279279 Args:
@@ -282,6 +282,7 @@ async def create_user(self, email: str, password: str, full_name: Optional[str]
282282 full_name: Optional full name for display
283283 is_admin: Whether user has admin privileges
284284 auth_provider: Authentication provider ('local', 'github', etc.)
285+ skip_password_validation: Skip password policy validation (for bootstrap)
285286
286287 Returns:
287288 EmailUser: The created user object
@@ -305,7 +306,8 @@ async def create_user(self, email: str, password: str, full_name: Optional[str]
305306
306307 # Validate inputs
307308 self .validate_email (email )
308- self .validate_password (password )
309+ if not skip_password_validation :
310+ self .validate_password (password )
309311
310312 # Check if user already exists
311313 existing_user = await self .get_user_by_email (email )
@@ -462,6 +464,10 @@ async def change_password(self, email: str, old_password: Optional[str], new_pas
462464 # )
463465 # success # Returns: True
464466 """
467+ # Validate old password is provided
468+ if old_password is None :
469+ raise AuthenticationError ("Current password is required" )
470+
465471 # First authenticate with old password
466472 user = await self .authenticate_user (email , old_password , ip_address , user_agent )
467473 if not user :
@@ -539,8 +545,8 @@ async def create_platform_admin(self, email: str, password: str, full_name: Opti
539545 logger .info (f"Updated platform admin user: { email } " )
540546 return existing_admin
541547
542- # Create new admin user
543- admin_user = await self .create_user (email = email , password = password , full_name = full_name , is_admin = True , auth_provider = "local" )
548+ # Create new admin user - skip password validation during bootstrap
549+ admin_user = await self .create_user (email = email , password = password , full_name = full_name , is_admin = True , auth_provider = "local" , skip_password_validation = True )
544550
545551 logger .info (f"Created platform admin user: { email } " )
546552 return admin_user
0 commit comments