Esempio n. 1
0
 public function actionLogin()
 {
     // Clear any logout redirect from any previous login.
     Oauth2::setSessionLogoutRedirect(null);
     // Then continue as normal
     return parent::actionLogin();
 }
Esempio n. 2
0
// Add links to either return home or to edit profile.
// Also include a link to redirect if one is stored in the session.
?>
<div class="row">
	<div class="col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4">
<?php 
if (Yii::$app->user->isGuest) {
    ?>
	<?php 
    echo Html::a(Html::encode('Return Home'), ['/'], ['class' => 'btn btn-default btn-lg btn-block']);
} else {
    ?>
	<?php 
    if ($linkName = Oauth2::getSessionRedirectName()) {
        ?>
		<?php 
        Oauth2::setSessionNoAuto();
        ?>
		<?php 
        echo Html::a(Html::encode('Continue to ' . $linkName), ['/site/first-registration-redirect'], ['class' => 'btn btn-primary btn-lg btn-block']);
        ?>
	<?php 
    }
    ?>
	<?php 
    echo Html::a(Html::encode('Edit your Profile'), ['/user/settings'], ['class' => 'btn btn-default btn-lg btn-block']);
}
?>
	</div>
</div>
Esempio n. 3
0
 public function redirectUser($noauth, $authdefault)
 {
     // Get any of supplied redirect params.
     $redirectData = Oauth2::redirectData();
     // Check if user is logged in.
     if (!Yii::$app->user->isGuest) {
         // Create redirect URL using current parameters if specified.
         $redirectURL = Oauth2::getSessionRedirectLocation($redirectData, true);
         // If the parameters created a valid redirect URL, go now.
         if ($redirectURL) {
             return $this->redirect($redirectURL);
         }
         // Failing that, send them to the auth default.
         return $this->redirect($authdefault);
     }
     // Not authenticated, send them to the non-authenticated page.
     // Store redirect information in session data if present.
     // Simplest way to reliably persist across any redirects.
     // Also persists across email activation links.
     if ($redirectData) {
         Oauth2::setSessionRedirect($redirectData);
     }
     return $this->redirect($noauth);
 }