Unable to create profile / authenticate

Issue #22 new
Sérgio Castro created an issue

Hi, I'm trying to integrate your (awesome) package in an app, but I'm having some issues with it. Here's some code, as it might help to understand the problem. I have setup the secret and ID tokens appropriately.

A link to login / auto-register if needed, that leads to the exact code the package has by default:

{{ link_to_route('anvard.routes.login', $provider, $provider) }}

When I click the link, I get redirected to / with no further notices. After inspecting where the redirect was in Anvard.php ...:

    public function attemptAuthentication($provider, Hybrid_Auth $hybridauth, $retry = 0) {
        try {
            $this->provider = $provider;
            $adapter = $hybridauth->authenticate($provider); // NOTHING IS EXECUTED AFTER THIS
            $this->setAdapter($adapter); 
            $this->setAdapterProfile($adapter->getUserProfile()); 
            $profile = $this->findProfile();
            return $profile;
        } catch (\Exception $e) {
            // uncomment this if you want more info
            //var_dump($e->getMessage());
            $this->errorCodes($e,$provider, $hybridauth, $retry);
        }
    }

And digging further in Auth.php ...

        Hybrid_Logger::info( "Enter Hybrid_Auth::authenticate( $providerId )" );

        // if user not connected to $providerId then try setup a new adapter and start the login process for this provider
        if( ! Hybrid_Auth::storage()->get( "hauth_session.$providerId.is_logged_in" ) ){ 
            Hybrid_Logger::info( "Hybrid_Auth::authenticate( $providerId ), User not connected to the provider. Try to authenticate.." );

            $provider_adapter = Hybrid_Auth::setup( $providerId, $params );

            $provider_adapter->login(); //FAILING HERE
        }

So, I'm really at a loss here. Basically, after failing the login() call, I get redirected to the homepage, without any profile information in the resulting array.

I'm testing my app locally but I have setup the exact same domain with Facebook (http://project.dev). If I use the Facebook Connect button manually, I do have the permissions to load the app in their popup (otherwise it would let me know my test user / my dev-mode FB App wasn't available). Any ideas on what could be wrong?

I'm sorry if this proves not to be a bug, but I didn't find any other resources that could hint me. Thanks in advance!

Comments (8)

  1. Nguyễn Đăng Khoa

    I have the same issue at you. I can not create new profiles (It's login well with an existing user in Users table)

  2. Goran A

    I am experiencing the same issue.

    Set everything according the instructions.

    I've set the credentials for facebook, google+ and twitter, and all I get is a redirect to the page I've set in config file, without any users (from the social login) inserted into the table profiles, and then on, no login session as well.

    I'm using Laravel 4.2, with Zizaco/Confide+Entrust and other packages.

    Any advice would be appreciated, and of great help.

    Thanks

  3. Goran A

    Nguyễn thank you for the reply.

    heres the error log.

    [2014-12-28 03:28:13] production.DEBUG: Anvard: attempting login [] [] [2014-12-28 03:28:13] production.DEBUG: Anvard: could not find profile, looking for email [] [] [2014-12-28 03:28:13] production.DEBUG: Anvard: did not find user, creating [] [] [2014-12-28 03:28:13] production.ERROR: Anvard: FAILED TO SAVE USER [] [] [2014-12-28 03:28:13] production.DEBUG: Anvard: login attempt complete [] [] [2014-12-28 03:28:13] production.DEBUG: Anvard: login failure [] []

  4. Nguyễn Đăng Khoa

    You should check your users table. Is there any column that not null and you didn't not config in db.php ?

    Here is my example : 'userrules' => array( 'password' => NULL, 'remember_token' => NULL, ),

  5. Goran A

    I'm not sure if I understood this quite well. I have : id, username, name, description, association, ringidno, address (NULL), postal (NULL), city, country, phone (NULL), email, www (NULL), facebook (NULL), twitter (NULL), googleplus (NULL), pinterest (NULL), youtube (NULL), skype (NULL), image (NULL), password (NULL), confirmation_code, remember_token (NULL), confirmed, created_at, updated_at.

    According to your example, should I be doing the following, or the opposite of these?

    'userrules' => array( 'address' => NULL, 'postal' => NULL, 'phone' => NULL, 'www' => NULL, 'facebook' => NULL, 'twitter' => NULL, 'googleplus' => NULL, 'pinterest' => NULL, 'youtube' => NULL, 'skype' => NULL, 'image' => NULL, 'password' => NULL, 'remember_token' => NULL, ),

    And what about: profiletousermap and uservalues ?

  6. Nguyễn Đăng Khoa

    Sorry for not clear before. I mean any columms that not nullable (will fails if there is no vaule when insert).

    
    

    You should do the opposite Profiletousermap to map some info from profile to your usertable. There is a issue about how to enable full logging

  7. Goran A

    I've added this values. I believe, they are correct, because previously I had a L4 error message for login.

    My models are the following (in the default models folder):

    <?php use Zizaco\Confide\ConfideUser; use Zizaco\Confide\ConfideUserInterface; use Zizaco\Entrust\HasRole;

    class User extends Eloquent implements ConfideUserInterface { protected $connection = 'mysql'; // static protected $table = 'users'; protected $primaryKey = 'username'; // id

    use ConfideUser; use HasRole; // Add this trait to your user model

    // HybrdiAuth public function profiles() { return $this->hasMany('Profile', 'users_id', 'id'); // } // HybridAuth

    ...

    }

    <?php

    class Profile extends Eloquent {

    protected $connection = 'mysql'; protected $table = 'profiles'; protected $primaryKey = 'id';

    protected $fillable = array('provider', 'users_id');

    // HybrdiAuth public function user() { return $this->belongsTo('User'); //, 'id', 'users_id' } // HybridAuth }

    'profiletousermap' => array( //'email' => 'email', // 'firstName' => 'forename', // 'lastName' => 'surname', 'username' => 'username', 'email' => 'email', 'address' => 'address', 'zip' => 'postal', //'city' => 'city', //'firstName' => 'name', 'firstName' => 'firstname', 'lastName' => 'lastname', 'phone' => 'phone', 'webSiteURL' => 'www', 'description' => 'description', //'facebook' => NULL, //'twitter' => NULL, //'googleplus' => NULL, //'pinterest' => NULL, //'youtube' => NULL, //'skype' => NULL, 'photoURL' => 'image', //'password' => NULL, //'remember_token' => NULL, ),

    'userrules' => array( 'id' => NULL, 'username' => NULL, 'name' => NULL, 'description' => NULL, 'association' => NULL, 'ringidno' => NULL, //'address' => NULL, //'postal' => NULL, 'city' => NULL, 'country' => NULL, //'phone' => NULL, 'email' => NULL, //'www' => NULL, //'facebook' => NULL, //'twitter' => NULL, //'googleplus' => NULL, //'pinterest' => NULL, //'youtube' => NULL, //'skype' => NULL, //'image' => NULL, //'password' => NULL, 'confirmation_code' => NULL, //'remember_token' => NULL,

    'confirmed' => NULL, 'created_at' => NULL, 'updated_at' => NULL, ),

    It still does no saving into the profiles and users table ...

    However, I'm looking into this the vendor files, and must ask the following

    vendor/.../.../.../Atticmedia/Anvard/AnvardServiceProvider.php

    Line 55: 'models' => $app['config']['anvard::models'], // there is not such file model in my published config files into /app/config/.../anvard/

    and regarding the functions in vendor/.../.../.../Atticmedia/Anvard/Anvard.php

    Line 64: $profile = $user->profiles()->first(); Line 66: $profile = $user->profiles()->where('network', $network)->first(); // what is the profiles() function, because I cannot find it defined anywhere ?

  8. Log in to comment