3
votes

I am interested in testing the incoming password field for a particular admin level password. If it matches, I want it to manually have Auth log in with whatever username they want (submitted via form)

My understanding is Auth, in taking the data, will only authorize it if it sees the same email/hashed password in the database. Is there a way to get around this check to manually set it? Even $this->Auth->login(..) will do this check right?

2

2 Answers

4
votes
$this->Auth->login($userId)

Auth::login accepts either a username/password combination or simply a user id (the primary key of the user model in the database).

0
votes

see my answer here: Using username instead of email in CakePHP's Auth Component

It's not the same question, but the idea is, when the login fails, you can intercept it and do what you want.