feat(api+testing): update member password and email verfied
This commit is contained in:
		@@ -86,3 +86,44 @@ async def insert_member(
 | 
			
		||||
            member = await curr.fetchone()
 | 
			
		||||
 | 
			
		||||
            return None if member is None else member
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def update_member_password(
 | 
			
		||||
    db: AsyncConnectionPool, id: int, password_hash: str
 | 
			
		||||
) -> bool:
 | 
			
		||||
    async with db.connection() as conn:
 | 
			
		||||
        async with conn.cursor(row_factory=class_row(Member)) as curr:
 | 
			
		||||
            query = sql.SQL(
 | 
			
		||||
                """
 | 
			
		||||
                UPDATE members
 | 
			
		||||
                    SET password_hash = (%s)
 | 
			
		||||
                    WHERE id = (%s)
 | 
			
		||||
                """
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            await curr.execute(
 | 
			
		||||
                query,
 | 
			
		||||
                (
 | 
			
		||||
                    password_hash,
 | 
			
		||||
                    id,
 | 
			
		||||
                ),
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            return curr.rowcount > 0
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def update_member_email_verified(db: AsyncConnectionPool, id: int) -> bool:
 | 
			
		||||
    async with db.connection() as conn:
 | 
			
		||||
        async with conn.cursor(row_factory=class_row(Member)) as curr:
 | 
			
		||||
            query = sql.SQL(
 | 
			
		||||
                """
 | 
			
		||||
                UPDATE members SET email_verified = now() WHERE id = (%s)
 | 
			
		||||
                """
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            await curr.execute(
 | 
			
		||||
                query,
 | 
			
		||||
                (id,),
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
            return curr.rowcount > 0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user