Giter Club home page Giter Club logo

cakephp-hybridauth's Issues

Is it possible to use both CakePHP default auth with the hybrid Auth?

Right now I am working on project where we need facebook and twitter login.
And I have also configure the login in my project but now its not authenticate with simple username and password.

This is AppController.php

class AppController extends Controller
{
    public function initialize()
    {
            $this->loadComponent('Flash');
            $this->loadComponent('Auth', [     
                'loginRedirect' => [
                    'controller' => 'Users',
                    'action' => 'index'
                ],
                'logoutRedirect' => [
                    'controller' => 'Users',
                    'action' => 'login'
                ],
                'authenticate' => [
                        'ADmad/HybridAuth.HybridAuth'
                ]
            ]);        
    }
}

Its working with only facebook and twitter login,and please let me know how to store user in database after successful login in fb or twitter.

Call to a member function primaryKey() on null

After authentication (after first registration), I'm getting this message :

Notice (8): Undefined variable: UsersTable [ROOT/vendor/admad/cakephp-hybridauth/src/Auth/HybridAuthAuthenticate.php, line 289]

Fatal Error
Cake\Error\FatalErrorException

Error: Call to a member function primaryKey() on null File /home/user10/public_html/app/vendor/admad/cakephp-hybridauth/src/Auth/HybridAuthAuthenticate.php Line: 289
How to fix this ?

Stopped working after upgrading to cakePHP 3.1.4

Hello Admad,

First off, this plugin has been so useful, thank you for making it.

Having an issue since upgrading to the newest version of CakePHP. Now when clicking on login from Google or Facebook, I'm logged in but never get redirect to the provider site and no provider_uid is generated.

screen shot 2015-11-13 at 12 31 32 pm

Keeps generating users in the database on every click, I've not changed any code and only noticed since upgrading.

Any ideas? I'll set up a blank project and see If I can replicate what is happening.

Thank you.

Not working after update

Hi,

I updated the Cake version to 3.1 and kept the plugin at the 4.0 branch (worked for me), however after this, the routes to login did not work anymore. For exemple:

/users/login?provider=Google

Gives this error:

Error: A route matching "array ( 'controller' => 'Users', 'action' => 'login', 'plugin' => NULL, '_ext' => NULL, )" could not be found. 

If I use any other word (or even left it blank) instead of ?provider= the routes work ok. Thus this made me believe there was something that changed, am I right or did I do something wrong?

Thanks!

Class 'Hybrid_Auth' not found

Hello @ADmad,

I'm trying to use your plugin from composer, but app doesn't start due to this error:

Fatal Error
Error: Class 'Hybrid_Auth' not found    
File:
C:\wamp\www\app\Plugin\HybridAuth\Controller\Component\Auth\HybridAuthAuthenticate.php  
Line: 141

Note: After adding hybridauth into require-dev of composer.json and execution composer update, it has been installed in C:\wamp\www\app\Vendor.

composer.json details:

"require": {
  "pear-cakephp/cakephp": ">=2.4.4"
  , "cakephp/debug_kit": ">=2.2.2"
  , "admad/cakephp-hybridauth": "dev-master"
},
"require-dev": {
  "phpunit/phpunit": "3.7.*"
  , "hybridauth/hybridauth": "dev-master"
}

Do you know what is wrong?

authenticated action will sometimes stall.

The authenticated action on the HybridAuthController will sometimes render a white page.

To reproduce visit the URL by manually entering the address.

http://www.example.com/hybrid_auth/authenticated

Sometimes when the OAuth process fails the user is left on this address with a white page. It should redirect to some of the auth redirect URLs.

Documentation

The documentation of this plugin says to check the examples of the Hybrid Auth docs but there is a red box on the page telling me this:

Please note that the examples are outdated and not production ready.
New examples are planned in one of the future releases.

So how do I set this up to work with a few different remote logins? FB, Twitter and Facebook to be specific.

Authentication does not return correct information

Hello,
after login i get few information of the user, this is the output of $this->Auth->identify()

[
    'identifier' => '102062xxxxxx',
    'webSiteURL' => '',
    'profileURL' => '',
    'photoURL' => 'https://graph.facebook.com/102062xxxxxx/picture?width=150&height=150',
    'displayName' => 'Name Surname',
    'description' => '',
    'firstName' => '',
    'lastName' => '',
    'gender' => '',
    'language' => '',
    'age' => null,
    'birthDay' => null,
    'birthMonth' => null,
    'birthYear' => null,
    'email' => '',
    'emailVerified' => '',
    'phone' => null,
    'address' => null,
    'country' => null,
    'region' => '',
    'city' => null,
    'zip' => null,
    'username' => '',
    'coverInfoURL' => 'https://graph.facebook.com/102062xxxxxx?fields=cover&access_token=xxxxxxx'
]

It is strange because i am using this scope email, public_profile, user_friends.

When i see the dialog on the facebook's page i correctly see that app is asking for email, public profile and friends, but the result does not have those information. Why?

App::import fails in component

I am trying to use your plugin with php 5.5.9 (ubuntu 14.04) and the following line
App::import('Hybridauth.Vendor', 'hybridauth/Hybrid/Auth') fails to import the file. Leading to a Class not found error. Instead i had to use require_once()

FWIW the current code runs just fine in php 5.5.3

You may or may not want to fix this...

Getting the information from the auth

Hi there.

First of all, thanks for this plugin, really great ;)

I'm trying to do something.

So on my Users/login, the users choose which social they want to login.. Lets imagine facebook. They click on it, authorize it and then I want it to redirect to a page where he writes extra information ( I know this is not usual, but it's how the platform is built, and we need some extra information from the user, such as VAT number and such)

I already got the redirect working properly ('hauth_return_to' => 'users/add'). Though, I don't know how in users/add.ctp get the user from social and fullfill my form with some information from

Thanks a lot!

Issue with google login for few users

In server error logs: I can see following message

Argument 1 passed to App\Model\Table\UsersTable::createUser() must be an instance of App\Model\Table\Event, instance of Cake\Event\Event given

And socialprofile & users both table dont have entry for these users

Migration does not run

Hello,

bin/cake migrations migrate -p ADmad/HybridAuth

does not create the table. I only see the phinx table with a strange name

a_dmad_hybrid_auth_phinxlog

Composer integration

Hello @ADmad,

First of all, congratulations for sharing your project. For me, this one is better than suggested by HybridAuth for CakePHP projects

Do you think about include composer.json and share it packagist.org? Currently, I'm using it to download CakePHP, or even DebugKit, and it's a good and usefull way to control third parties in projects and their upgrades.

Thanks.

Profile returns not matching passed provider

What I'm doing

  • I'm testing my sign in in my browser.
  • I have Google, Facebook and Twitter
  • I am using a query param ?provider=Twitter etc, as detailed in the docs
  • I have redirected my live url example.com to my localhost so that OAuth callback urls resolve correctly.
  • I am forcibly using exit inside my createUser() method to see the web service return and my newly built UserEntity.

What is happening
After trying Twitter for example, I then refresh my login page and click to sign in with Google, and I get a Twitter response.

What I'm expecting
My expectation would be that the return of $event->data()['profile'] would match the provider passed in the query param.

What could be happening?
I've not done too much investigation at this point, but I can only imagine that there is some caching of the web service response somewhere. It's worth noting that this behaviour doesn't happen all the time, and seems to be triggered by sending many request, so could be a side effect of development.

I wanted to raise an issue for a number of reasons. Firstly so that I know I won't forget it. Secondly so if anyone else hits the issue we can collate thoughts, and thirdly to get some input on potential failure points and things to debug.

Listener in UsersTable.php doesn't work

Hi,
I have a plugin in which I have a Users controller and Model. I followed all the steps you mentioned and added the listener in UsersTable.php of my plugin but when the callback from Google arrives the execption in line 339 of HybridAuthAuthenticate.php is triggered and I see the error : "You must attach a listener for "HybridAuth.newUser" event which saves new user record and returns an user entity."
Could you help me please?

Removing Session Dependency

I'm trying to set this up as a social login for an AngularJS project. Cake is acting as my REST API, and I'm not storing any session data elsewhere. I simply plan on passing in a token on each request for authentication. All I need is for this to manage the OAuth callback and then issue a token back to the AJAX request. Do I need Sessions enabled for that?

[improvement] Add option for fields.

Right now the plugin stores all of the user record fields in the session. Would be nice if the config could define what fields should be stored.

Instagram Login

Hi,
I am going to use the version for CakePhp 2.4+ but I am not sure that Instagram login is working properly? As I found some LinkedIn typos in Instagram provider, I've been in doubt if it's working.

Thanks in advance.

Multi-providers login

Hello,
looking at the login page we simple do $user = $this->Auth->identify();
The problem here should be if we manage more providers. Because the identify() method calls the provider login page but what if we have many, what happen ?

How should we set the specific provider we need to identify?

callbacks/extensionpoints for authenticated action

It would be nice to have extension points for HybridAuthController::authenticated().
This way we can execute the same after login logic like the normal login would, or via protected AppController method use the same one for both.

Ideally there is one for the success (e.g. logincounter raise) and one for the error case (e.g. flash message).

Why adding a new user into Authenticate file?

Hi,
looks a bit strange to me adding a new user inside the authenticate file. If i can ask, why this choice? I think we should trigger the newUser event and then all the logic must be in the controller.

A new type of authentication should check if it is able to authenticate the user, nothing else.
Do we need a refactorization?

Route does not exist

Hi =)

<?= $this->Html->link(
                    'Login with Facebook',
                    ['controller' => 'Users', 'action' => 'login', '?' => ['provider' => 'Facebook']]
                ); ?>

After being authentified by facebook when i go back to the login page and click again on the facebook connexion, i'm getting

Error: A route matching "array ( 'controller' => 'users', 'action' => 'login', 'prefix' => false, 'plugin' => 'ADmad/HybridAuth', '_ext' => NULL, )" could not be found.

Do i have to setup a route in routes.php ?

The passed context was:

[
'_base' => '',
'_port' => '80',
'_scheme' => 'http',
'_host' => 'www.myprivatedomain.com',
'params' => [
'plugin' => 'ADmad/HybridAuth',
'controller' => 'HybridAuth',
'action' => 'authenticated',
'_ext' => null,
'pass' => [],
'_matchedRoute' => '/hybrid-auth/authenticated'
]
]

Call to a member function api() on array

Cant post to page. I got all needed params but when I try to execute $pages->api()->api( "/" . $pages['data'][0]['id'] . "/feed", 'post', $params ); i get
Call to a member function api() on array

Migration Fails: Foreign key constraint is incorrectly formed

This is for the 4.0 branch. When I attempt to create the social_profiles table, the following occurs:

Welcome to CakePHP v3.1.2 Console
---------------------------------------------------------------
App : src
Path: /var/www/blah/src/
PHP : 5.6.4-4ubuntu6.3
---------------------------------------------------------------
using migration path /var/www/blah/vendor/admad/cakephp-hybridauth/config/Migrations
using environment default
using adapter mysql
using database nom_dev

 == 20150813000000 CreateSocialProfiles: migrating



  [PDOException]                                                                                                                                   
  SQLSTATE[HY000]: General error: 1005 Can't create table `blah`.`social_profiles` (errno: 150 "Foreign key constraint is incorrectly formed")  



migrate [-t|--target TARGET] [-d|--date DATE] [-p|--plugin PLUGIN] [-c|--connection CONNECTION] [-s|--source SOURCE]

Issue with $this->request->is('post')

Hi,

I've tried your plugin and i've setup my facebook application but I have to press the button twice in order to login.

I've narrowed it down to if ($this->request->is('post')) { in the controller login function. This returns false when you first submit this form.

    <?php
        echo $this->Form->create('User');
        echo $this->Form->input('provider', array('value' => 'Facebook'));
        echo $this->Form->end('Submit');
    ?>

Apparently the first time you click to login with facebook, the plugin via the library communicates well with facebook servers but then it won't go straight into $this->Auth->login() (to actually log you in the first time) because when it comes back from facebook through the endpoint it's not a post anymore and that's why when you press the button to login with facebook a second time, it will work because it already has the facebook stuff stored in session and then its actually a post.

I haven't tried other services yet.
Thanks.

Later EDIT
Twitter behaves the same way, having to submit the form twice because it stops at the same if condition, the request that comes back from twitter is not post so it doesn't go into $this->Auth->login()

mysql table name

can you change table name from social_profiles to something else?
i tried changing this 'profileModel' => 'ADmad/HybridAuth.SocialProfiles', and this $this->hasMany('ADmad/HybridAuth.SocialProfiles');
but still ain working.
please help

view problem

first of all i would like to say sorry for posting such a stupid question, i have download this plugin and loaded to my application and configure my controller and config file as defined, but i cannot see any info that tells my how should i configure my login.ctp file, i tried to implement the src/template/login.ctp code found in the repo but that doesnt work in my app. i cannot see any link that says login with facebook and others. can you please point out to correct doc if any i am using cake 3

providers btn

Dear ADmad,
Im beginner for cakePHP, I just installed your plugin and confused about how put my provider btn in login page.
if you can explain me more.
thanks

Undefine Index provider

Hi Admad,

Authentication not respond. Then I change HybridAuthAuthenticate.php on Line : 239

from : $provider = $data[$fields['provider']];
with : $provider=$data['provider'];

I am not sure but it work now.

Great & Simple Plugin
Thank bro.

Change redirect url with code

I have the following problem.
What I want is that of a user press a link to /baskets/save to redirect him to login and then later on to /baskets/save again.
In /baskets/save:
if(!$this->Auth->user()) {
$this->request->session()->write('goto', ['controller' => 'Baskets', 'action' => 'save']);
return $this->redirect('/users/login');
}

and in users/login:
if($goto && count($goto) > 1)
$this->Auth->redirectUrl(array_merge($goto, ['plugin' => false]));

but then I get an error:
Error: A route matching "array ( 'controller' => 'Users', 'action' => 'login', 'plugin' => 'ADmad/HybridAuth', '_ext' => NULL, )" could not be found.

The error occurs in HybridAuthController.php on line 50:
if ($user) {
$this->Auth->setUser($user);
return $this->redirect($this->Auth->redirectUrl()); <------------- here
}

What am I doing wrong?

Plugin Admad/HybridAuth could not be found.

When I run bin/cake migrations migrate -p ADmad/HybridAuth to generate table it gives

Plugin Admad/HybridAuth could not be found. in [/var/www/html/site/vendor/cakephp/cakephp/src/Core/Plugin.php, line 148]

$this->Auth->user()

After a successfull login, the info about the user should be on $this->Auth->user() or not ?
I guess not because mine isn't.

I did some research on the plugin and library code, and found the info on $_SESSION["HA::STORE"]['hauth_session.provider.user']. You plan put it on Auth->user() ? I tried to do this, but i don't understand very well about Components.

Sry for bad english

Case Sensitive

Hey dude, me again :P
I developed all my website using Windows, but when I put it on my server (runs Linux) it got some fatal erros. Just little things like this
Just creating the issue to let you know this

[bug] Should fetch user entity as an array.

HybridAuthAuthenticate current fetches the user record as an CakePHP entity. This causes the AuthComponent to return the user record as an entity for the first time, but later when the user is fetched from the session it's an array.

This breaks code because $this->Auth->user()->id is valid only when it's not from the session.

Associated roles table not returned

I am using ADmad/CakePHP-HybridAuth with dereuromark/cakephp-tinyauth with multi role facility. I wrote following code in my AppController.php:

    $this->loadComponent('TinyAuth.Auth', [
            'autoClearCache' => true,
            // 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],
                ]
            ],
            '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'
                ]
            ]
         ]);

When I try to login using form it returns associated roles, but when try to login using HybridAuth not returned the roles. FYI, authentication and authorization works for both case.

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.

FYI, when I save new user using \Cake\Event\EventManager::instance()->on('HybridAuth.newUser', [$this, 'createUser']);, my associated roles saved successfully.

How can I retrieve roles using HybridAuth?

fields-parameter is missing

Hi,

i started to work with this plugin on CakePHP3 and login works. But the userdata returning from facebook just includes username and id. it not includes i.e. email.

i didn't found a way to set fields-parameter for "/me?fields=..."
is there a way to get this data from your plugin?

Unable to access `redirectUrl()`

I've run into the following fatal error attempting to login after installing HybridAuth:

Notice (8): Undefined property: HybridAuthAuthenticate::$_registry [ROOT/Plugin/HybridAuth/Controller/Component/Auth/HybridAuthAuthenticate.php, line 104]
Notice (8): Trying to get property of non-object [ROOT/Plugin/HybridAuth/Controller/Component/Auth/HybridAuthAuthenticate.php, line 104]

I rolled my version of Cake back to the 2.4 branch to check if this might be a result of any core changes that have happened since, but I see the same error whether using 2.4, 2.5, or 2.6.

To fix this I access the Auth settings through $this->_Collection instead of $this->_registry. I will submit a PR with these changes now, but please let me know if I'm doing something wrong on my end to run into this issue.

(P.S., I now realize I have only tested this on top of the FriendsOfCake/app-template project skeleton. I'm going to double-check this with a ๐Ÿฆ install of Cake and report back here if I run into the same issue.)

Callback for HybridAuth.newUser event is never attached

I found a problem attaching the method to handle new registrations.
At the moment i have:

    public function beforeFilter(Event $event)
    {
        parent::beforeFilter($event);
        EventManager::instance()->on('HybridAuth.newUser', [$this, 'socialRegistration']);
    }

the problem is that the UsersController is never called, HybridAuthController instead because the provider is calling the authenticated method there.

If i put the same beforeFilter inside the AppController it works perfectly, but adding the callback for registration there does not sounds good.

is there any workaround?

Email field in social_profiles is useless

Hi!
Why should we use the email field inside social_profiles table?
In the users table we already have email field. When we use two or more socials we use that field to understand if the user is already registered. social_profiles.email is only a "clone" of that field, looks useless to me. What do you think?

3.4 support for query string redirects

Just a small heads up and reminder ticket once 3.4 becomes beta/stable
We should add support for query string redirects then, so the referrer after login still is applied as so far with session approach.

[request] - Make Cake3 branch the master

Now that CakePHP 3.0 is released. Can the Cake3 branch become the master, and the master be branched for Cake2.

I'm not sure how this would impact composer, but Cake2 doesn't use composer. So people would just have to remove the branch reference.

The plugin should maybe use a release tag as well.

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.