Skip to content

Conversation

taskibayev
Copy link

Q A
Is bugfix? no
New feature? yes
Breaks BC?
Tests pass? no
Fixed issues comma-separated list of tickets # fixed by the PR, if any

@taskibayev
Copy link
Author

taskibayev commented May 22, 2018

hello
probably i should open an issue before creating PR.

So why i did it (created PR)?

i'm working with CMS LUYA. and developing a account module for my project (project is not in github).

i faced some problems when tried to configurate User component in app configuration. (which could be accessed by Yii::$app->getUser())

I confugurated User component in my account module (which colud be accessed by Yii::$app->getModule('account')->getUserIdentity() )

And i used this yii2-authclient to implement social-net-work authorization.

After successfully authoration yiisoft/yii2-authclient redirects to url, which is retrived from Yii::$app->getUser(), which is app component.

But i need to retrieve url from my module user component Yii::$app->getModule('account')->getUserIdentity()

So in this PR i implemented ability to set user component by configuration.

Code would like this:
`
public function actions()

{
    return [
        'auth' => [
            'class' => 'yii\authclient\AuthAction',
            'successCallback' => [$this, 'onAuthSuccess'],
            'user' => Yii::$app->getModule('account')->getUserIdentity(),
        ],
    ];
} 

`

* @var instance of \yii\web\User
* user component, which might be set in different module
*/
public $user;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should allow setting ID of the component as well as configuration array instead of user instance only i.e. https://github.com/yiisoft/yii2/blob/master/framework/BaseYii.php#L342

@samdark samdark added the type:enhancement Enhancement label May 23, 2018
@samdark samdark added this to the 2.2.0 milestone May 23, 2018
@taskibayev
Copy link
Author

confused with amend commit, so 1 commit turned into 2 commits. I'm not that strong with git, totaly confused with reverting commit.
So "setting user component id instead of user instance" sets component id
and "mend" some corrections in comments

@samdark
Copy link
Member

samdark commented Jun 15, 2018

@lab362 please check if #230 works for you. Thanks.

@samdark samdark closed this Jun 15, 2018
@samdark samdark removed this from the 2.2.0 milestone Mar 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:enhancement Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants