The action hook wp_login runs when the user logs in - it can run a simple function. The real breadwinner here is wp_authenticate which has a bit of documentation.