pub async fn get_user_by_email(pool: &Pool<MySql>, email: &str) -> Result<User>Expand description
Retrieves a user by their email address.
This function fetches a user record based on their email address, which serves as a unique identifier in many authentication and user management scenarios. It’s commonly used during login processes and for email verification.
§Arguments
pool- Database connection pool for executing the queryemail- Email address of the user to retrieve
§Returns
Ok(User)- Successfully retrieved user informationErr(anyhow::Error)- Failed to fetch user (including if not found)
§Error Handling
Returns an error if no user with the given email exists or if a database error occurs during the query execution.