Auth authentication is lost on CakePHP without permission

Asked 2 years ago, Updated 2 years ago, 58 views

Currently, CakePHP implements Auth authentication using users table UsersController.php.

The users directory continues to log in, but
If you fly to another directory, you will be in a logout state without permission.

What can you think of when this happens?
If you know anything, please let me know.

By the way, in order to work with Facebook authentication, we do not provide default authentication such as Form authentication.
Also refer to the this code.

php cakephp

2022-09-30 16:24

1 Answers

If the http://fuzzydevelopment.net/cakephp-facebook-374.html code remains the same, the login process is incorrect and will not work.

$user=$this->User->find('first', ['conditions'=>['User.id'=>$facebookId]]);
    if(!empty($user['User']))}
        if($this->Auth->login($user['User'])){
            $this->redirect(['action'=>'index']);
        }
    } else{
        $this->_add();
    }

appears to call the _add method when no user is found, but you are not logged in because you did not set the user in the login session.

If you want Facebook authentication, you should use https://github.com/uzyn/cakephp-opauth or https://github.com/ADmad/CakePHP-HybridAuth/tree/cake2.

You may also want to create your own Authenticate class using documents for study purposes.

Creating Custom Authentication Objects
http://book.cakephp.org/2.0/ja/core-libraries/components/authentication.html#id6


2022-09-30 16:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.