Giter Club home page Giter Club logo

Comments (11)

ADmad avatar ADmad commented on August 20, 2024

I see you have added 'finder' => 'auth' for your Form authenticator, why haven't you done the same for ADmad/HybridAuth.HybridAuth's config?

from cakephp-hybridauth.

monsurhoq avatar monsurhoq commented on August 20, 2024

I also try that, I told on my message.

from cakephp-hybridauth.

ADmad avatar ADmad commented on August 20, 2024

I told on my message.

Not clear enough :) All you said was HybridAuth does not return roles.

from cakephp-hybridauth.

monsurhoq avatar monsurhoq commented on August 20, 2024

I am using CakePHP 3.3.5. I also try using contain, which have been deprecated as of 3.1, but no roles return for HybridAuth. I also try my custom finder findAuth for HybridAuth, no change.

Yes, HybridAuth does not return roles using 'finder' => 'auth' in ADmad/HybridAuth.HybridAuth's config

from cakephp-hybridauth.

ADmad avatar ADmad commented on August 20, 2024

HybridAuth does take the finder into account.

from cakephp-hybridauth.

monsurhoq avatar monsurhoq commented on August 20, 2024

This my new code:

        $this->loadComponent('TinyAuth.Auth', [
            'autoClearCache' => Configure::read('debug'),
            // followings are common setting for auth component
            'authenticate' => [
                 'Form' => [
                    'finder' => 'auth'
                 ],
                 'ADmad/HybridAuth.HybridAuth' => [
                    'fields' => [
                        'provider' => 'provider',
                        'openid_identifier' => 'openid_identifier',
                        'email' => 'email'
                    ],
                    'profileModel' => 'ADmad/HybridAuth.SocialProfiles',
                    'profileModelFkField' => 'user_id',
                    'hauth_return_to' => ['controller' => 'Users', 'action' => 'index', 'prefix' => false, '_ext' => null],
                    'finder' => 'auth'
                ]
            ],
            'loginAction' => [
                'controller' => 'Users',
                'action' => 'login',
                'prefix' => false
            ],
            'loginRedirect' => [
                'controller' => 'Users',
                'action' => 'index',
                'prefix' => false
            ],
            'logoutRedirect' => [
                'controller' => 'Users',
                'action' => 'login',
                'prefix' => false
            ],
            'flash' => [
                'element' => 'error',
                'key' => 'auth'
            ],
            // using bootstrap ui for flash element
            'flash' => [
                'element' => 'error',
                'key' => 'auth'
            ],
            'authorize' => [
                // check authorization using TinyAuth based on config/acl.ini settings
                'TinyAuth.Tiny' => [
                    'multiRole' => true,
                    'autoClearCache' => true,
                    'superAdminRole' => '01',
                    'rolesTable' => 'roles',
                    'pivotTable' => 'roles_users'
                ]
            ]
         ]);

And this my finder in UsersTable.php

    public function findAuth(\Cake\ORM\Query $query, array $options)
    {
        $query
            ->contain(['Roles'])
            ->where(['Users.isactive' => 1,'Users.activationkey IS' => null]);

        return $query;
    }

Roles not return.

from cakephp-hybridauth.

ADmad avatar ADmad commented on August 20, 2024

You can step through the code and check whether the finder you set is being used at the line i linked.

from cakephp-hybridauth.

monsurhoq avatar monsurhoq commented on August 20, 2024

That block executed, when a new user try to login with hybridauth first time. But when user information save into database, after then when same user try to login using hybridauth, that block not executed.

        if ($profile && !empty($profile->user)) { // this is for old user
            $user = $profile->user;
            $profile->unsetProperty('user');
        } elseif ($providerProfile->email) { // this is for new user
            pr($config['finder']);
            $user = $this->_userModel->find($config['finder'])
                ->where([
                    $this->_userModel->aliasField($config['fields']['email']) => $providerProfile->email
                ])
                ->first();
            pr($user);
            die();
        }

from cakephp-hybridauth.

ADmad avatar ADmad commented on August 20, 2024

Okay, I see the problem. Will make a fix.

from cakephp-hybridauth.

ADmad avatar ADmad commented on August 20, 2024

I have made a new release with the fix.

from cakephp-hybridauth.

monsurhoq avatar monsurhoq commented on August 20, 2024

Thanks. It is working now.

from cakephp-hybridauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.