File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Yii Framework 2 authclient extension Change Log
4
4
2.1.8 under development
5
5
-----------------------
6
6
7
+ - Enh #218 : Allow configuring user component in ` AuthAction ` (samdark, lab362)
7
8
- Bug #237 : Fix redirect from LinkedIn if user refused to authorize permissions request (jakim)
8
9
9
10
Original file line number Diff line number Diff line change 11
11
use yii \base \Exception ;
12
12
use yii \base \InvalidConfigException ;
13
13
use yii \base \NotSupportedException ;
14
+ use yii \di \Instance ;
14
15
use yii \helpers \Url ;
15
16
use yii \web \Response ;
16
17
use yii \web \HttpException ;
17
18
use yii \web \NotFoundHttpException ;
18
19
use Yii ;
20
+ use yii \web \User ;
19
21
20
22
/**
21
23
* AuthAction performs authentication via different auth clients.
@@ -109,6 +111,12 @@ class AuthAction extends Action
109
111
*/
110
112
public $ redirectView ;
111
113
114
+ /**
115
+ * @var User|array|string the User object or the application component ID of the user component.
116
+ * @since 2.1.8
117
+ */
118
+ public $ user = 'user ' ;
119
+
112
120
/**
113
121
* @var string the redirect url after successful authorization.
114
122
*/
@@ -118,6 +126,14 @@ class AuthAction extends Action
118
126
*/
119
127
private $ _cancelUrl ;
120
128
129
+ /**
130
+ * @inheritdoc
131
+ */
132
+ public function init ()
133
+ {
134
+ parent ::init ();
135
+ $ this ->user = Instance::ensure ($ this ->user , User::className ());
136
+ }
121
137
122
138
/**
123
139
* @param string $url successful URL.
@@ -165,7 +181,7 @@ public function getCancelUrl()
165
181
*/
166
182
protected function defaultSuccessUrl ()
167
183
{
168
- return Yii:: $ app -> getUser () ->getReturnUrl ();
184
+ return $ this -> user ->getReturnUrl ();
169
185
}
170
186
171
187
/**
@@ -174,7 +190,7 @@ protected function defaultSuccessUrl()
174
190
*/
175
191
protected function defaultCancelUrl ()
176
192
{
177
- return Url::to (Yii:: $ app -> getUser () ->loginUrl );
193
+ return Url::to ($ this -> user ->loginUrl );
178
194
}
179
195
180
196
/**
You can’t perform that action at this time.
0 commit comments