R
R
raisatic1552021-08-13 14:55:47
Vue.js
raisatic155, 2021-08-13 14:55:47

VUE + JS ajax account password reset not working?

The site has an authorization with a "forgot password" button,
the layout itself is of this kind

<el-form id="forgotEmailForm" v-if="forgotFormAuth == true" :rules="rulesForgot" :model="model" ref="model" style="height: unset" label-width="200px" class="form-login" label-position="top" :status-icon="true">
          <h1 style="margin-bottom: 10px;">Password recovery</h1>
          <el-form-item label="Email" prop="Email">
            <el-input type="text" v-model="model.USER_LOGIN" name="USER_LOGIN"></el-input>
          </el-form-item>
          <el-input style="display: none" v-model="model.USER_EMAIL" type="text" name="USER_EMAIL"></el-input>
          <el-input style="display: none" v-model="model.backurl" type="text" name="backurl"></el-input>
          <el-input style="display: none" v-model="model.AUTH_FORM" type="text" name="AUTH_FORM"></el-input>
          <el-input style="display: none" v-model="model.TYPE" type="text" name="TYPE"></el-input>
          <el-input style="display: none" v-model="model.forgot_password" type="text" name="forgot_password"></el-input>
          <el-input style="display: none" v-model="model.send_account_info" type="text" name="send_account_info"></el-input>
          <el-form-item>
            <div style="display: flex; justify-content: space-between; margin-top: 15px;">
              <el-button style="padding: 12px 0; width: 140px;" type="primary" @click="loginFormAuthClick()">Back</el-button>
              <el-button style="padding: 12px 0; width: 140px;" type="primary" @click="submitFormForgot('model')" :loading="loading">Send</el-button>
            </div>
          </el-form-item>
          <div v-if="message" class="error">{{message}}</div>
        </el-form>


when the button is clicked, the submitFormForgot('model') send function is triggered, which makes an ajax redirect to the file with the form to send a link to reset the password.
The password recovery layout itself:
<form name="bform" method="post" target="_top" id="formForgot" action="<?=$arResult["AUTH_URL"]?>">
    <?
    if (strlen($arResult["BACKURL"]) > 0)
    {
        ?>
        <input type="hidden" name="backurl" value="<?=$arResult["BACKURL"]?>" />
        <?
    }
    ?>
    <input type="hidden" name="AUTH_FORM" value="Y">
    <input type="hidden" name="TYPE" value="SEND_PWD">

    <p><?echo GetMessage("sys_forgot_pass_label")?></p>

    <div style="margin-top: 16px">
        <div><b><?=GetMessage("sys_forgot_pass_login1")?></b></div>
        <div>
            <input type="text" name="USER_LOGIN" value="<?=$arResult["LAST_LOGIN"]?>" />
            <input type="hidden" name="USER_EMAIL" />
        </div>
        <div><?echo GetMessage("sys_forgot_pass_note_email")?></div>
    </div>

    <div style="margin-top: 20px">
        <input type="submit" name="send_account_info" value="<?=GetMessage("AUTH_SEND")?>" />
    </div>
</form>


How to make the form work for password recovery?
The logic now is this:
In authorization, they press the "recover password" button -> an ajax request occurs with a json parameter e-mail to recover -> a file with a password recovery form is called, where I receive the entered email via json and, in theory, should send the form to receive a link to the mail to reset the password, but for some reason the form is not sent. I tried to simulate a form submit click through js, but the scripts seem to not work, they are stupidly absent, I even tried to call a simple document.write (), but did not give out anything.
What can you think of?

The php password recovery form itself is fully functional if you go directly to the page where this form is,
you need to make it work from the vue template via ajax

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question