Stop showing blank page on cancelled login - Ember - javascript

I have searched for answers with no luck on my problem and thus I hope you can provide me with some help.
My company is using Ember.js, which I have very little knowledge of, and one of our current user stories is to make it possible to show the user something else than a blank page on cancelled login prompt. I have tried making cancel actions etc in the ex-button-Component and login-controller (sorry but cannot show that code), but with no visible change.
The solution could either be a redirection to a page ("you pressed cancel!"), some sort of alert ("ey, you cancelled!") or simply go back to the login prompt.
I provide you with the code for the login template below:
<form class="form-signin" role="form">
<h2 class="form-signin-heading">{{t 'logon.title' logonIdBinding="logonId"}}</h2>
{{#if logonFailed}}
{{show-alert error=true message=errorMessage}}
{{/if}}
{{input type="text" value=logonId placeholder=(t "logon.username") class="form-control"}}
{{input type="password" value=password placeholder=(t "logon.password") class="form-control"}}
{{ex-button icon="fa fa-upload" type="submit" _type="primary" clicked="logon" isLoading=isLoading text=(t 'button.login')}}
</form>

Related

Php Go back to previous page form resubmit

I have the following three php files:
reports.php, bwdates-reports-details.php and visitor-detail.php
reports.php contains my form which inputs the from and to date (erased some parts for brevity):
<form method="post" action="bwdates-reports-details.php">
...
<input type="date" id="fromdate" name="fromdate">
...
<input type="date" id="todate" name="todate">
<button type="submit" name="submit">Submit</button></p>
</form>
bwdates-reports-details.php outputs whatever parameters inputted in "fromdate" and "todate" of reports.php, see image below
As you can see in the image, there is an option to view the details of a transaction by clicking the "View Details" icon - i class="fa fa-edit fa-1x".
In view details (visitor-detail.php), There is a "Go Back" button.
<div align="center">
<button onclick="goBack()">Go Back</button>
</div>
There is also a goBack javascript function:
<script>
function goBack() {
window.history.back();
}
</script>
But when the go back button is clicked, I am getting Confirm Form Resubmission error. What I wanted to achieve with the "go back" button is to be able to go back to bwdates-reports-details.php with all the variables I passed through in reports.php. How do I achieve what I wanted to do? Please take note that this isn't a purchase related website. php or javascript will do. Thanks!
If a form is submitted (probably with the POST method), you send this data to the new page that is then opened. This page is also added to the history not only with the URL but also the sent data.
If you then leave this page and want to navigate back to this previous page you will get an "Resubmission" error, because the browser would need to send the data again to do so, but that is probaby a bad thing to do, because the data of the form would be sent twice. (Imagine that was a purchase form and the client would buy everything again.)
To make your goBack function work there are no other ways than get rid of that form submission page somehow or put a page in between that is not a form-data-receiver.
The best way would be to not go back in the browser history if you don't know from what pages the user navigated to this. Instead just navigate to an overview or dashboard.
Edit:
If that page your working on is only accessible by that response page of the form, maybe going two pages back will fix your error: history.back(2);
Because your form is using POST method and when you click on goBack button, it goes on previous page without variables. You may use put dates variable with goBack button and also use
if(isset($_GET['your variable name'];
{`fetch your variables`}
on your previous page.
Desired result was achieved by using the GET method instead of POST method (see https://www.tutorialspoint.com/php/php_get_post.htm). reports.php form code was replaced from:
<form method="post" action="bwdates-reports-details.php">
to:
<form method="get" action="bwdates-reports-details.php">
In bwdates-reports-details.php where I have the following variables:
$fdate=$_POST['fromdate'];
$tdate=$_POST['todate'];
Instead I replaced it with:
$fdate=$_GET['fromdate'];
$tdate=$_GET['todate'];
The goback javascript function I have in visitor-detail.php stays the same. And works like a charm. Thanks and cheers!

Form gives validation error every time unless page is refreshed

I have a php/html/form that is giving me problems. What happens is the form gives me validation error upon submitting unless I refresh the page and get it correct the first time. If I input incorrect validation then I must refresh the page again or else it will give me error over and over. And it must be correct the very first time after page load, or else it will just keep giving error until you refresh and get it right the.very first time.
After that I am would like to pass the user submitted data to the next page using PHP.
<form action='load' method='GET' onsubmit="return Validate();">
<div>
<input type="text" placeholder="Enter btc address" name="btcaddress" pattern="^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$" oninvalid="setCustomValidity('Correct address format required.')" required>
</div>
<center>
<button type="submit"><b>Go</b></button>
</center>
</form>
Could this be happening because I am testing on my Linux machine with Atom and the PHP Server plugin? Address http://localhost:8000

Google Apps Script: submit form + keep window content + make browser make an offer to save name/password

I´m trying to submit a HTML form while keeping content of displayed page on the screen and triggering browser to make an offer to save username and password.
<div id="signInForm" class="init">
<form>
<input id="username" type="text" placeholder="Username">
<br><br>
<input id="password" type="password" placeholder="Password">
<br><br>
<button type="submit">Sign in</button>
</form>
</div>
I´ve found out, that keeping content can be done various ways:
preventDefault(), onsubmit="return false", action="javascript:".
I successfully made work each of them. But each of them prevents browser (Chrome and Edge) from doing an offer of saving username and password. As long as I´ve learnt, an HTML form has a default behavior on submit which is navigating to the submission link. My theory is that the "navigating event" itself is what triggers an offer to save username and password. If I´m right, the only way to reach my goal is probably based on letting submission happen default way, while making browser keep the content somehow.
Bur all I ever get after hitting <button type="submit">Sign in</button> is a blank page.
Is it even possible to overcome this simply in Apps Script? Or am I missing something basic?
I tried to programmatically reload my page, but wasn´t able to do so. I don´t know how to work with reload().
I´ve tried this:
<!DOCTYPE html>
<html>
<body>
<div id="x">I´m ORIGINAL page</div>
<button onclick="document.getElementById('x').innerHTML= 'I´m EDITED page';">edit page</button>
<br>
<button onclick="myFunction()">Reload page</button>
</body>
<script>
function myFunction() {
window.location.reload(true);
}
</script>
</html>
The snippet above works for me in Stackoverflow snippet editor, but it doesn´t work in my published GAS web app.
EDIT Probably close to solution for my problem is answer in this post: Redirecting from doPost() in Google Web App, HTML form with App script where the author suggests this:
<form method="post" action="<?!= ScriptApp.getService().getUrl() ?>">
<input type="submit" value="submit">
</form>
But it does nothing for me when copied and pasted and I don´t know how to implement it any other way. It looks general...
I was having the same issue when trying to avoid the page to reload to a blank page. The solution that worked for me was a piece of code that is on Google Apps Script Documentation (I leave the link here)
I hope this solution can help you to solve the blank reloading issue.
<script>
// Prevent forms from submitting.
function preventFormSubmit() {
var forms = document.querySelectorAll('form');
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener('submit', function(event) {
event.preventDefault();
});
}
}
window.addEventListener('load', preventFormSubmit);
</script>

Complex web site login with Requests

I'm trying to log in to a site using the requests module, and can't figure out how the site's login page actually works. Here's the relevant form:
<form class="ui-corner-all" method="POST" id="login" target="_top">
<div id="lift__noticesContainer__"></div>
<label for="username">Username</label><br>
<input value="" id="username" type="text" name="F783713994214KVBZZQ">
<label for="password">Password</label><br>
<input value="" id="password" type="password" name="F7837139942151QISNM">
<p><a data-at="e45a1d" href="/forgot_pwd">Forgot password?</a></p><br>
<button class="btn btn-primary" type="submit" name="F783714094216F0PPFD" value="_">LOGIN</button>
</form>
I think the name of the fields are both randomly generated (F783713994214KVBZZQ and F7837139942151QISNM), so I parse those out, but I'm not sure what to do with that information. There's no login page url specified that I can see. I've tried constructing a payload of the above strings and correct login info and posting it with no result.
When I watch the network activity in chrome's inspector, after I click the login button I can see a post to the site but there's no query string parameters (where I would expect to see the username & password).
Does anyone know what else I should be looking at to figure out where the username and password are going and how to access that via requests?
Full login page html: https://pastebin.com/vP1s9esZ
My code: https://pastebin.com/4jG13WfW
The page includes a login.js in the header, but it's only this:
$(document).ready(function() {
$("#username").focus();
// Centers the div
$("#login").position({
of: window,
at: "center center"
});
});
Thanks in advance for any help!
You're looking for Selenium if you want to automate the login flow. But, if you want to make a request to the site, start with the network monitor. Click login and grab the request that goes to the site. They would either send it as a form or a payload.
Read more of the same at What's the difference between "Request Payload" vs "Form Data" as seen in Chrome dev tools Network tab

How to post the form tag action value in ejs?

is there any know that?
I'm testing some javascript as follows
function mem_join_next() {
if (document.mem_join.email.value == "") {
alert("please input your email ID");
document.mem_join.email.focus();
return;
}
document.mem_join.submit();
}
<form name="mem_join" action="/join_step_3" method="post">
<div class="col-xs-12 id">
<p><span>EMAIL</span><span class="star">*</span>
</p>
<input name='email' class="email1" type="text" style="IME-MODE: disabled" size="11">#
<input class="email2" type="text">
<div class="email-check">email_check</div>
</div>
<div class="col-xs-6 next" align="right">
<a onClick="mem_join_next()" style="cursor:pointer">
<img src="/page_imgs/member_img/btn-next.jpg">
</a>
</div>
It's code what i want to run.
But when It is processing, the screen come out the 404 not found error.
even it is right route.
I think the post is not working
cause if i go straight way to single URL address(localhost/join_step_3) , the screen come out the /join_step_3 address screen.
but if i go From join_step_2 form next button TO join_step_3, It is 404 not found please hell me! GOD PROGRAMMERS!
If you directly typed the url and it worked means the page at localhost/join_step_3 worked using GET, because the browser url uses the GET Method.
So, it is quite possible that your localhost/join_step_3 doesn't support POST Method. Therefore, either add the post support on the page depending on the server-side scripting you use, or change method="post" to method="get" in your client html.

Categories

Resources