A
A
Alexander Verbitsky2020-02-11 01:50:27
Yii
Alexander Verbitsky, 2020-02-11 01:50:27

How to set up rendering when logging in via dektrium/yii2-user social networks?

There is a form for comments, it is located under the blog article:
5e41dc4f57bcd897041890.png
As you can see, you can enter the name and email yourself, or log in through social networks and leave a comment.

But the problem is that after logging in via social networks, the page reloads, and the user finds himself in the header of the article, and in order to leave a comment, he needs to go down the page again...

Is it possible to somehow configure the login so that only the block with comments is updated? like with ajax...

In web.php I have it configured like this:

'modules'      => [
  'user' => [
    'class' => 'dektrium\user\Module',
      'security' => [
        'class' => \dektrium\user\controllers\SecurityController::className(),
        'on ' . \dektrium\user\controllers\SecurityController::EVENT_BEFORE_AUTHENTICATE => function ($e) {
          /**
          * В контроллере ArticleController сохранил путь - \yii\helpers\Url::remember('', 'actions-article');
          * И здесь получил его:
          **/
          
          $previous = yii\helpers\Url::previous('actions-article');
// Если путь сохранен, то он переходит на эту страницу, если нет, то на главную
          if($previous) {
            Yii::$app->user->setReturnUrl(Yii::$app->request->hostInfo.$previous);
          } else {
            Yii::$app->user->setReturnUrl(Url::home());
          }
        },
      ],
    ],
  ],
]


Is there an article somewhere on this topic? I can’t find it anywhere ... The second day is already in the search ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-02-11
@VerbAlexVlad

Is it possible to somehow configure the input so that only the block with comments is updated? like with ajax...

Why don't you like ajax?
Or, after logging in via social networks, redirect to the desired #comment anchor, which was specified in the HTML layout.
public function actionLogin()
{   
    //your code for login
    
   return $this->redirect(['profile', 'id' => $id, '#' => 'comment']);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question