PHPackages                             yiicod/hauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. yiicod/hauth

AbandonedArchivedYii-extension[Authentication &amp; Authorization](/categories/authentication)

yiicod/hauth
============

0.2.0(10y ago)261New BSD LicensePHP

Since Jun 8Pushed 10y ago1 watchersCompare

[ Source](https://github.com/yiicod/hauth)[ Packagist](https://packagist.org/packages/yiicod/hauth)[ RSS](/packages/yiicod-hauth/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (10)Used By (0)

Hauth extensions
================

[](#hauth-extensions)

This is extension for simple integrate social signup/signin. For social connect used extension hybridauth/hybridauth. In this extension implement yii events and evenement (optional. With yiicod/evenement extension you can build powerfull events listener for all what you whant).

You can extend HybridAuthBehavior and write what you want on events:

- findUser
- connect
- error

If you want install to extensions folder, insert into composer.json:
--------------------------------------------------------------------

[](#if-you-want-install-to-extensions-folder-insert-into-composerjson)

```
"require": {
    "composer/installers": "1.0.3"
}
```

Config ( This is all config for extensions. Many from this items is optinal)
----------------------------------------------------------------------------

[](#config--this-is-all-config-for-extensions-many-from-this-items-is-optinal)

```
'components' => array(
    'hauth' => array(
        'modelMap' => array(
            // You can change field names or models
            'SocialAuth' => array(
                'alias' => 'yiicod\hauth\models\SocialAuthModel',
                'class' => 'yiicod\hauth\models\SocialAuthModel',
                'fieldUserId' => 'userId',
                'fieldProvider' => 'provider',
                'fieldIdentifier' => 'identifier',
                'fieldCreateDate' => 'createDate',
            ),
            'User' => array(
                'alias' => 'yiicod\auth\models\UserModel',
                'class' => 'yiicod\auth\models\UserModel',
            )
        ),
        'controllers' => array(
            'controllerMap' => array(
                'default' => array(
                    'socialAuth' => 'yiicod\hauth\controllers\SocialAuthController',
                ),
            ),
            'default' => array(
                'socialAuth' => array(
                    'layout' => '',
                    'filters' => array('accessControl'),
                    'accessRules' => array(
                        array(
                            'allow',
                            'actions' => array('connect'),
                            'users' => array('?')
                        ),
                        array(
                            'allow',
                            'actions' => array('callback'),
                            'users' => array('*')
                        ),
                        array(
                            'deny',
                            'actions' => array(),
                            'users' => array('*')
                        )
                    ),
                ),
            ),
        ),
        'hybridAuthBehavior' => 'yiicod\hauth\controllers\behaviors\HybridAuthBehavior',
        'components' => array(
            //You can set callback and providers what you want to use.
            'hybridAuth' => array(
                'class' => 'yiicod\hauth\components\HybridAuth',
                'callbackRoute' => '/socialAuth/callback',
                'providers' => array(
                ),
                'debugMode' => false,
                'debugFile' => '',
            ),
        ),
    )
)

'preload' => array('hauth')
```

If you want extend SocialAuthController you should set (For exclude duplicate controller):
------------------------------------------------------------------------------------------

[](#if-you-want-extend-socialauthcontroller-you-should-set-for-exclude-duplicate-controller)

```
'components' => array(
    'hauth' => array(
        'controllers' => array(
            'controllerMap' => array(
                'default' => array(
                    'socialAuth' => null,
                ),
            ),
        )
    )
)
```

Using exampale
--------------

[](#using-exampale)

```
namespace app\modules\auth\controllers\behaviors;

/**
 * SocialAuth behavior with event for controller action
 * @author Orlov Alexey
 */

use

class HybridAuthBehavior extends HybridAuthBaseBehavior
{

    private function uniqueName($name)
    {
        retrun ;
    }

    /**
     * User find event
     * @param CEvent $event Object has next params sender -> SocialAuthController,
     * params -> array('model' => UserModel)
     */
    public function userFind($event)
    {
        parent::userFind($event);

        $data = $event->params['data'];
        $userModel = $event->params['userModel'];
        $providerProfile = $event->params['providerProfile'];

        $userAttrs = Yii::app()->db->createCommand()
                ->select('*')
                ->from('User')
                ->where('email=:email', array(':email' => $providerProfile->email))
                ->queryRow();
        if ($userAttrs === false && $data['action'] == 'signup') {
            $userModel->setScenario('signup.social');
            $userModel->userName = $this->uniqueName(preg_replace('/\s/', '', $this->sanitizeTitleWithTranslit($providerProfile->displayName)));
            $userModel->email = empty($providerProfile->email) ? (md5($providerProfile->identifier) . '@' . $data['provider'] . '.com') : $providerProfile->email;
            $userModel->password = $userModel->getOpenUserPassword();

            if ($userModel->save()) {
                $data['isNewUser'] = true;
                $data['identifier'] = $providerProfile->identifier;
            }
        } elseif(is_array($userAttrs)) {
            $userModel->setAttributes($userAttrs);
            $userModel->setPrimaryKey($userAttrs['id']);
        }

    }

    /**
     * Connect event
     * @param CEvent $event Object has next params sender -> SocialAuthController,
     * params -> array('model' => UserModel)
     */
    public function connect($event)
    {
        parent::connect($event);

        $userModel = $event->params['userModel'];
        $identity = new $userIdentity(, );
        if (!$identity->authenticate() || !Yii::app()->user->login(identity) {
            if ($event->params['data']['action'] == 'signup') {
                Yii::app()->user->setFlash('error', Yii::t('', 'We are sorry but we can not register you.'));
            } else {
                Yii::app()->user->setFlash('error', Yii::t('', 'We are sorry but we can not login you.'));
            }
        }
        Yii::app()->request->redirect(Yii::app()->createAbsoluteUrl('/user/dasboard'));
        Yii::app()->end();
    }

    public function error($event)
    {
        parent::error($event);
        Yii::app()->user->setFlash('error', Yii::t('', 'We have some problem, try again later.'));
        Yii::app()->request->redirect(Yii::app()->createAbsoluteUrl('/login'));
        Yii::app()->end();
    }

}
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~66 days

Total

9

Last Release

3777d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7934283ca98b7f31bb5bf13119a8495cad80ac9097125a48792f47caddb588b9?d=identicon)[lexxorlov](/maintainers/lexxorlov)

---

Top Contributors

[![lexxorlov](https://avatars.githubusercontent.com/u/7910574?v=4)](https://github.com/lexxorlov "lexxorlov (9 commits)")

### Embed Badge

![Health badge](/badges/yiicod-hauth/health.svg)

```
[![Health](https://phpackages.com/badges/yiicod-hauth/health.svg)](https://phpackages.com/packages/yiicod-hauth)
```

###  Alternatives

[mageplaza/magento-2-social-login

Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps

1841.2M5](/packages/mageplaza-magento-2-social-login)[socalnick/scn-social-auth

Uses the HybridAuth PHP library to Enable authentication via Google, Facebook, Twitter, Yahoo!, etc for the ZfcUser ZF2 module.

21975.0k3](/packages/socalnick-scn-social-auth)[abydahana/aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based), just by writing single controller. Yet it's reusable, scalable and ready to use!

1111.2k](/packages/abydahana-aksara)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
