Authenticating against external and then internal databases in rails

A system I’m building requires us to authenticate against our clients database to pull user information from their database. However, they also want us to allow external users to log in and access this system. To authenticate against their database we’re using DeviseLDAPAuthenticatable, and were planning on using Devise to add local users.
The plan of action at the high level is:

User puts in log in details
if ldap accepts these
log in
elseif local database excepts these
log in
What I'm guessing is that I need to override the authenticate_user! method but it didn't seem obvious what I'd need to include to make sure that the LDAP users could still log in.