GuidovTricht
GuidovTricht

Reputation: 33

Fix authentication cakePHP

What I did

The CakePHP version is 2.2.3

I used this part of the Cookbook to create my authentication: Link After i was finished, i changed the fields to email and password (in AppController.php):

public $components = array(
        'Session',
        'Auth' => array(
            'authenticate' => array(
                'Form' => array('userModel' => 'User', 'fields' => array('username' => 'email', 'password' => 'password'))
            ),
            'loginRedirect' => array('controller' => 'twitter', 'action' => 'index'),
            'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),
            'authorize' => array('Controller')
        )
    );

What happened

When i log in with my credentials, it redirects me to the loggedin page, even when the credentials aren't correct!

I hope someone can help me with the problem. Thanks in advance!

EDIT: Login now works as far as i can see! But the logout doesnt work. It doesnt remove my session.

Upvotes: 0

Views: 98

Answers (1)

dogmatic69
dogmatic69

Reputation: 7585

You are passing something to $this->Auth->login($something). The code has changed since 1.x and anything passed to this method will cause the user to be logged in.

You should call $this->Auth->login() with no parameters

Upvotes: 1

Related Questions