mirror of
				https://github.com/fastapi-users/fastapi-users.git
				synced 2025-11-04 06:37:51 +08:00 
			
		
		
		
	* Move users router in sub-module * Factorize UserRouter into EventHandlersRouter * Implement OAuth registration/login router * Apply isort/black * Remove temporary pytest marker * Fix httpx-oauth version in lock file * Ensure ON_AFTER_REGISTER event is triggered on OAuth registration * Add API on FastAPIUsers to generate an OAuth router * Improve test coverage of FastAPIUsers * Small fixes * Write the OAuth documentation * Fix SQL unit-tests by avoiding collisions in SQLite db files
		
			
				
	
	
		
			21 lines
		
	
	
		
			479 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			479 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from typing import Tuple
 | 
						|
 | 
						|
from passlib import pwd
 | 
						|
from passlib.context import CryptContext
 | 
						|
 | 
						|
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
 | 
						|
 | 
						|
 | 
						|
def verify_and_update_password(
 | 
						|
    plain_password: str, hashed_password: str
 | 
						|
) -> Tuple[bool, str]:
 | 
						|
    return pwd_context.verify_and_update(plain_password, hashed_password)
 | 
						|
 | 
						|
 | 
						|
def get_password_hash(password: str) -> str:
 | 
						|
    return pwd_context.hash(password)
 | 
						|
 | 
						|
 | 
						|
def generate_password() -> str:
 | 
						|
    return pwd.genword()
 |