Added implementation of the after_login function