I'm running a login form, which - in case of success - forwards the user to a specific page via JS location.href. The browsers correctly recognize the form as a login form and offer to save the password. Now only in Google Chrome, the prompt disappears once the location changes. So the prompt is visible for just a split second, making it impossible to save the password.Is there any solution for this? Refreshing after login success is a common thing, so there should be a way to fix this..
Edit:
This is what the form looks like:
<form id="loginform" action="process.php" target="processframe" method="POST">
<input id="login_name" name="name" type="text" placeholder="Username"><br>
<input id="login_password" name="password" type="password" placeholder="Password"><br>
<button>Submit</button>
</form>
<iframe src="" id="processframe" name="processframe" style="display:none;"></iframe>
So the request is processed in an iframe. process.php then calls a javascript function:
window.setTimeout("parent.loginsuccess()", 1000);
The loginsuccess() function:
function loginsuccess()
{
location.href="/home.php";
}
Related
I have an existing project in asp.net core 2.1 mvc. In the login page, I added forget password link and I wanna make like this thing; When user click this link, other page appear then user entered own email adress and click send buton then password reset link gonna user's email when user click password reset link user entered new password and confirm new password. How can i do this. There are so many resource but generaly in .net core identity but I dont use identity.
You can use session to reset the password.
The bakend
public IActionResult ForgetPassword()
{
//email: send a random code and save it in a session
HttpContext.Session.SetString("randomcode",new Random().Next(1000,10000).ToString());
return View();
}
[HttpPost]
public IActionResult ForgetPassword(string password,string randomCode)
{
//if the Vertification Code is not equals to the randomcode, return fail
if (randomCode != HttpContext.Session.GetString("randomcode"))
{
return View();
}
//update database
return View("index");
}
Give the new password in this form.
<form action="/home/ForgetPassword" method="post">
Password :<input type="text" name="password" value="" />
Confirm Password :<input type="text" name="confirm_password" value="" />
Vertification Code: <input type="text" name="randomCode" value="" />
<input type="submit" name="reset" value="reset"
onclick="Confirm(event)"/>
</form>
javascript
<script>
function Confirm(e) {
var passw = document.getElementsByName('password')[0].value
var confirmPassw = document.getElementsByName('confirm_password')[0].value
if (passw != confirmPassw)
e.preventDefault()
}
</script>
I have been getting a 400 error, and cut the code down to a very basic form post, and still get this error.
It happens once only on first attempt (i.e. first time page is loaded ever, then, go back, press button, and all ok)
I have found that it is related to "antiforgery", and if i disable this, all works perfect first time
<div class="text-center">
<form method="post">
<button id="btnLogin" type="submit" asp-page-handler="BtnSignin">Login</button>
</form>
The above is my HTML, and below is the c#:
public async Task<IActionResult> OnPostBtnSignin()
{
return null;
}
(i know returning null isnt ideal, but, for my debugging, it confirms if i get the 400 error or not)
if I publish (to aws lambda), on first button press, it errors, go back, press button, and this time, no error
if i disable "antiforgery", it works (have tried, and its consistent either way round)
Any ideas on why? and how to fix? (without disabling antiforgery)
Try to add #Html.AntiForgeryToken() to your form:
<form method="post">
#Html.AntiForgeryToken()
<button id="btnLogin" type="submit" asp-page-handler="BtnSignin">Login</button>
</form>
Both <form method="post"></form> and #Html.AntiForgeryToken() will result in the __RequestVerificationToken hidden field being added to the page.So if your form cannot add __RequestVerificationToken to page,you can try to add #Html.AntiForgeryToken().
Recently $nexttick appears to have broken on IE 11, in particular regarding input bound variable. This is causing forms with dynamic content to submit missing the required data
<form id="something" action="/" method="post">
<input type="hidden" name="token" :value="token" />
</form>
// js code
promise.then(function() {
self.$nextTick(function () {
document.getElementById('something').submit();
});
});
We have found that using the setTimeout for 1 second around the form submission allows enough time for the DOM to be updated so the token can be included in the form submission.
Has there been any changes to nexttick / IE11 that we need to account for?
nextTick allows you to do something after you have changed the data and VueJS has updated the DOM based on your data change, but before the browser has rendered those changed on the page. If you want to explicitly re-render the DOM, use requestAnimationFrame or setTimeout.
You could check this thread.
I am trying to create a simple web app in google scripts with the HTML api.
code.gs
function doGet() {
return HtmlService.createHtmlOutputFromFile('index');
}
function processForm(formObject) {
var formBlob = formObject.myFile;
var driveFile = DriveApp.createFile(formBlob);
return driveFile.getUrl();
}
index.html
<script>
function updateUrl(url) {
var div = document.getElementById('output');
div.innerHTML = 'Got it!';
}
</script>
<form id="myForm">
<input name="myFile" type="file" />
<input type="button" value="Submit"
onclick="google.script.run
.withSuccessHandler(updateUrl)
.processForm(this.parentNode)" />
</form>
<div id="output"></div>
The form fails to submit. I´m using google chrome Versión 30.0.1599.101 m
This appears in the console: Uncaught NetworkError: Form submission failed.
Here is the app: https://script.google.com/d/1yrgM20n1ZI99bChN2qtQWgGck36OccLN3A16Gn7tCPvsJw0EcK_ql7C5/edit?usp=sharing
Maybe you should add encoding="multipart/form-data" attribute to form tag.
If not solved already – did you try changing the input type from "button" to "submit"? On top of that I'd also try giving it another value than "Submit" since that might interfere with the actual submit parameter.
I want to click the submit button of the webpage i am displaying in my Web Browser but it seems not to work at all here is my code:
WebBrowser1.Document.Forms(0).InvokeMember("image")
i was basing on the html code of the button i want to click which is:
<div class="buttonRow forward">
<input type="image" src="includes/templates/template_default/buttons/english/button_send.gif" alt="Send Now" title=" Send Now ">
</div>
did i miss something? i really need help.
Try setting this property
Webbrowser.AllowNavigation = True