I haven’t done it using an external database, but I have done it using third party.
Do you happen to know where it goes wrong for you? are you successfully getting the password from your external database?
I think I’d also move the log-in process to the backend in a .jsw file, then if successful you can use generateSessionToken() to generate a token that you return to the front-end, then use applySessionToken() to log the user in.