mercredi 2 octobre 2019

Bypassing Ember validation while injecting a user and pass with jquery val

As a hobby I am trying to build my own username and password storage to inject via chrome plugin from site to site.

It works fine with the usual $('#username').val() However I am coming up against an issue on a site that was built with ember. The site has a form like this:

<form class="login_form" novalidate="" data-ember-action="" data-ember-action-7="7" _lpchecked="1">
    <div id="ember4" class="fieldset fieldset--error fieldset--empty fieldset--material ember-view"> <label for="username" class="fieldset_label">Username</label> <input name="username" id="username" class="input username" autocomplete="off" autofocus=""></div>
</form>

The problem is when I use $('#username').val("myUsername");

I get an error that says "please enter a username". The thing is if I go into the input, press any key, and then delete the text that I added it validates because it removes fieldset--error and fieldset--empty which then allows me to press submit and it works.

The thing is - how do I solve this in a programmatic way? Is there a way to tell Ember to stop pestering me to manually type instead of using .val()?

Or is there a way to trick it into thinking I did (because jquery.trigger doesn't work)




Aucun commentaire:

Enregistrer un commentaire