Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

francisceril's avatar

Possible to make Authentication from a custom query?

First of, here's my issue. I have an Oracle database table Users which I have no control at all. So I would like to use it for authentication only.

I get an Inconsistent datatypes error when I try to run this query, select * from users. I didn't dig deep to which column/s is giving me this error as I only need the username and password fields.

Thus, when I specify the columns like select username, password from users, I don't get an error.

My question is. Is it possible to make the Authentication against my custom query?

0 likes
1 reply
Snapey's avatar

You cant control the other db but you can implement your own user table and make sure its hashed correctly

  • get login form from user
  • attempt login. if it works then all is good, redirect them within your application
  • if login fails, check if there is a local account for them. If so then password must be keyed wrong, return error
  • see if you can validate username and password against other database
  • if not, return error as earlier
  • if username and password were correct, create local user account, hash their plaintext password and log them in to laravel
  • redirect as per your earlier success path

considerations

  • you must know how the password is stored in the other system
  • users have two distinct login credentials. over time their passwords coukd be out of sync

Please or to participate in this conversation.