Closed gugoan closed 8 years ago
Hmmm I've never used this so I'm not exactly sure how it works. However it looks like you just need to enter the login url/info, something like this:
Restricted url - http://example.com/user/profile
Login url - http://example.com/user/login
Login method - POST
Parameter - LoginForm[email]
Parameter - LoginForm[password]
What error are you getting?
I tried exactly that, but the message below in the PARAMETER field: These characters are not allowed: [,]
Hmm then I'd recommend making a separate login page. Add the input fields manually so they won't have the brackets, ie, email instead of LoginForm[email].
You can load the params using:
// DefaultController
public function actionLogin()
{
/** @var \amnah\yii2\user\models\forms\LoginForm $model */
$model = $this->module->model("LoginForm");
// load post data and login
$post = Yii::$app->request->post();
// if ($model->load($post) && $model->validate()) {
if ($model->load($post, "") && $model->validate()) {
$returnUrl = $this->performLogin($model->getUser(), $model->rememberMe);
return $this->redirect($returnUrl);
}
return $this->render('login', compact("model"));
}
That other page I would enter the input fields in HTML anyway? and use that actionLogin ?
You can just create a whole new function/page, something like public function actionLogin2()
. It would contain the exact same code with two changes
// DefaultController
public function actionLogin()
{
// ...
$model->load($post, ""); //instead of $model->load($post)
// ...
return $this->render('login2', compact("model")); // instead of 'login'
}
Then create the login2.php view file with the input fields.
I can not understand very well, see this as my control actionLogin:
public function actionLogin2()
{
$model = Yii::$app->getModule("user")->model("LoginForm");
if ($model->load(Yii::$app->request->post()) && $model->login(Yii::$app->getModule("user")->loginDuration)) {
return $this->goBack(Yii::$app->getModule("user")->loginRedirect);
}
return $this->render('login2', [
'model' => $model,
]);
}
$model->load($post, ""); // note the second parameter ""
this allows you to use html input email instead of LoginForm[email]
right!
In my manual test worked, but when testing on CRAWLER ACCESS appears Bad Request (# 400) Do you know why ?
Hmm probably csrf. Try disabling it
finally worked: D thank you
Any security risk to keep a second page login to be used by CRAWLER?
Ummm if someone finds it, then possibly. You may want to consider adding a third parameter with a private key/hash.
Yes Thanks man
Hello, I am trying to follow the instructions on the link below to publish ads on the pages of members. However I am unable to validate the data.
Can you give me an example of how it would look fields filled?
https://support.google.com/adsense/answer/161351?hl=en
http://www.webnots.com/adsense-crawler-access-to-password-protected-pages/