PHP 클래스 yii\authclient\AuthAction

It supports OpenId, OAuth1 and OAuth2 client types. Usage: php class SiteController extends Controller { public function actions() { return [ 'auth' => [ 'class' => 'yii\authclient\AuthAction', 'successCallback' => [$this, 'successCallback'], ], ] } public function successCallback($client) { $attributes = $client->getUserAttributes(); user login or signup comes here } } Usually authentication via external services is performed inside the popup window. This action handles the redirection and closing of popup window correctly.
또한 보기: Collection
또한 보기: yii\authclient\widgets\AuthChoice
부터: 2.0
저자: Paul Klimov ([email protected])
상속: extends yii\base\Action
파일 보기 프로젝트 열기: yiisoft/yii2-authclient 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$clientCollection name of the auth client collection application component. It should point to Collection instance.
$clientIdGetParamName name of the GET param, which is used to passed auth client id to this action. Note: watch for the naming, make sure you do not choose name used in some auth protocol.
$redirectView name or alias of the view file, which should be rendered in order to perform redirection. If not set - default one will be used.
$successCallback PHP callback, which should be triggered in case of successful authentication. This callback should accept [[ClientInterface]] instance as an argument. For example: php public function onAuthSuccess($client) { $attributes = $client->getUserAttributes(); user login or signup comes here } If this callback returns [[Response]] instance, it will be used as action response, otherwise redirection to [[successUrl]] will be performed.

공개 메소드들

메소드 설명
getCancelUrl ( ) : string
getSuccessUrl ( ) : string
redirect ( mixed $url, boolean $enforceRedirect = true ) : Response Redirect to the given URL or simply close the popup window.
redirectCancel ( string $url = null ) : Response Redirect to the [[cancelUrl]] or simply close the popup window.
redirectSuccess ( string $url = null ) : Response Redirect to the URL. If URL is null, [[successUrl]] will be used.
run ( ) Runs the action.
setCancelUrl ( string $url )
setSuccessUrl ( string $url )

보호된 메소드들

메소드 설명
auth ( mixed $client ) : Response Perform authentication for the given client.
authOAuth1 ( OAuth1 $client ) : Response Performs OAuth1 auth flow.
authOAuth2 ( OAuth2 $client ) : Response Performs OAuth2 auth flow.
authOpenId ( OpenId $client ) : Response Performs OpenID auth flow.
authSuccess ( yii\authclient\ClientInterface $client ) : Response This method is invoked in case of successful authentication via auth client.
defaultCancelUrl ( ) : string Creates default [[cancelUrl]] value.
defaultSuccessUrl ( ) : string Creates default [[successUrl]] value.

메소드 상세

auth() 보호된 메소드

Perform authentication for the given client.
protected auth ( mixed $client ) : Response
$client mixed auth client instance.
리턴 yii\web\Response response instance.

authOAuth1() 보호된 메소드

Performs OAuth1 auth flow.
protected authOAuth1 ( OAuth1 $client ) : Response
$client OAuth1 auth client instance.
리턴 yii\web\Response action response.

authOAuth2() 보호된 메소드

Performs OAuth2 auth flow.
protected authOAuth2 ( OAuth2 $client ) : Response
$client OAuth2 auth client instance.
리턴 yii\web\Response action response.

authOpenId() 보호된 메소드

Performs OpenID auth flow.
protected authOpenId ( OpenId $client ) : Response
$client OpenId auth client instance.
리턴 yii\web\Response action response.

authSuccess() 보호된 메소드

This method is invoked in case of successful authentication via auth client.
protected authSuccess ( yii\authclient\ClientInterface $client ) : Response
$client yii\authclient\ClientInterface auth client instance.
리턴 yii\web\Response response instance.

defaultCancelUrl() 보호된 메소드

Creates default [[cancelUrl]] value.
protected defaultCancelUrl ( ) : string
리턴 string cancel URL value.

defaultSuccessUrl() 보호된 메소드

Creates default [[successUrl]] value.
protected defaultSuccessUrl ( ) : string
리턴 string success URL value.

getCancelUrl() 공개 메소드

public getCancelUrl ( ) : string
리턴 string cancel URL.

getSuccessUrl() 공개 메소드

public getSuccessUrl ( ) : string
리턴 string successful URL.

redirect() 공개 메소드

Redirect to the given URL or simply close the popup window.
public redirect ( mixed $url, boolean $enforceRedirect = true ) : Response
$url mixed URL to redirect, could be a string or array config to generate a valid URL.
$enforceRedirect boolean indicates if redirect should be performed even in case of popup window.
리턴 yii\web\Response response instance.

redirectCancel() 공개 메소드

Redirect to the [[cancelUrl]] or simply close the popup window.
public redirectCancel ( string $url = null ) : Response
$url string URL to redirect.
리턴 yii\web\Response response instance.

redirectSuccess() 공개 메소드

Redirect to the URL. If URL is null, [[successUrl]] will be used.
public redirectSuccess ( string $url = null ) : Response
$url string URL to redirect.
리턴 yii\web\Response response instance.

run() 공개 메소드

Runs the action.
public run ( )

setCancelUrl() 공개 메소드

public setCancelUrl ( string $url )
$url string cancel URL.

setSuccessUrl() 공개 메소드

public setSuccessUrl ( string $url )
$url string successful URL.

프로퍼티 상세

$clientCollection 공개적으로 프로퍼티

name of the auth client collection application component. It should point to Collection instance.
public $clientCollection

$clientIdGetParamName 공개적으로 프로퍼티

name of the GET param, which is used to passed auth client id to this action. Note: watch for the naming, make sure you do not choose name used in some auth protocol.
public $clientIdGetParamName

$redirectView 공개적으로 프로퍼티

name or alias of the view file, which should be rendered in order to perform redirection. If not set - default one will be used.
public $redirectView

$successCallback 공개적으로 프로퍼티

PHP callback, which should be triggered in case of successful authentication. This callback should accept [[ClientInterface]] instance as an argument. For example: php public function onAuthSuccess($client) { $attributes = $client->getUserAttributes(); user login or signup comes here } If this callback returns [[Response]] instance, it will be used as action response, otherwise redirection to [[successUrl]] will be performed.
public $successCallback