That custom database login script is specific to that database. If they are logging in using a social provider that would be considered a separate connection from a custom DB.
Depending on what you want to accomplish during those scripts, rules would likely be the best route for simple verification. Rules are run on each successful login/authentication, regardless of connection type. You could write a rule to verify that user against your own database. Then, if they are not in your DB, you could limit access, disable account, require further action etc.
Another robust option would be to use account linking to link that users social and custom DB accounts. This gives you access to all the information from both sources. More on that here. Keep in mind, this requires the user to share the same email in both the custom DB and the social provider.
Does that answer your question?