I want to have a simple authentication for a website, just for testing purpose. On opening the site for ex: www.example.com the browser should ask user to enter a username and password to navigate to index.html.
How can I do this in JavaScript, I don't mind hard coidng the user name and password. I do not want any database connection. Its a simple 3 page static site deployed in a server. Index.html loads on opening the site.
Store the valid user name and password in local javascript variables. On the click event of your login button, compare the input values to your local variables. As long as this is for testing, it will work.
Related
I am trying to write a test for a webApp that has only an email-only-signIn. That means the user hacks in the email and clicks on the link he receives in an email.
In order to test a user signUp I was wondering what you think I could do to solve the problem?
I test with Jest and Puppeteer.
My app is made only of Html, CSS and JS.
Many thanks ahead,
Alex
I would see some way, you could :
Open the web app, sign up.
In another page (browser.newPage()), you open your classic email provider.
You have to instrument the whole email connection, and then open the last email and clikc on the embedded link.
Now it can be complicated, especially for the email instrumentation part.
Perpahs the best way could to use a temporary email :
https://temp-mail.org/en/
This way, you still have to open two different pages (one for the temp email, one for your app) but then it's easier to fetch the email received (and you're sure it's this one and not another one) and you can click on it to confirm the sign-up on your app.
I want to create a log in with javascript and html. I use prompt when someone create a new user and password. I would like to know how to save the created password and user locally.
My code works but when I close the web browser, you have to create another username and password each time you want to come back to the website. I need to have something that will save the created password and username that the user create with prompt. This user and password will be use for the log in even if we close the web page. Thanks a lot.
The best way to do that locally (I hope this is for entertainment purposes only because what you are doing is clearly not secure) would be to store it as a cookie.
I recommend checking out this nice stackoverflow post talking about setting and unsetting cookies with jquery. How do I set/unset cookie with jQuery?
I am working on internal website, which is used only within the company. The requirement for one of its pages is to log-in to our vendor sites (which are all on different domains).
For this I open these vendor sites within an iframe of the internal website.
Say,
Internal site: us.com
Vendor sites: foo.com, bar.com
On us.com/openvendor , there are two options: foo and bar. When a user clicks on foo, the iframe within the page opens foo.com in signed in state.
To achieve this, I replicate the login form of foo.com and post all the required parameters like username, password etc. to foo.com's page. I have all the usernames and passwords of different vendors stored in database.
Why do I do this? Because we don't want the users of this site(mostly our CRM team) to know the passwords (lest they use it to do unwanted and untracked transactions) and the activities done through us.com is recorded and saved.
So essentially, we enable users to login to any vendor site, just by clicking on a link.
This was working perfectly fine until one day, when I had to add a new vendor site which doesn't post an html form for authentication. This site (say whattodo.com) makes an ajax call to a url with login credentials, which returns back an authentication cookie. This cookie is then set by the site to make the user logged in.
Now how can I make my end users login to whattodo.com on a click?
I cannot make the ajax call to whattodo.com
Even if I overcome the above problem by storing the auth cookie value in my database and updating it monthly(ya that's when the cookie expires), I cannot set this cookie under whattodo.com domain in the user's browsers.
Please suggest a possible solution.
And please feel free to edit the title. I'm sure there's a better one to summarize the question.
I am currently developing a website where I am facing the following problem:
I tried passing the User id and password to the login page and auto submit the page using a script, which will take the user to the next page. This is just to bypass the login page in my site. This works perfectly fine.
When the "No script" add on is enabled on a Mozilla Firefox browser, the script to auto submit the form is not working. As a result, the login page is getting displayed to the user with the filled in user id and password.
Also, sometimes the user is able to see the login page on the front end when we auto submit the login page.
Are there any possible ways to overcome these two issues?
Redirecting the user's browser as you are doing now is really only possible client side with Javascript, which is always able to be blocked. You could store the user_id and password in a session variable and access that data on your login page which handle's the actual authentication. Doing it that way would eliminate the need for auto submitting forms.
But if you really want to use form posting you can emulate a form post with PHP using cURL, but this is a little more complicated.
cURL on php.net
Sending post form data with PHP and cURL
On my site, if the user is not logged in I run a "tryCookieAuthentication" method on every page load which checks to see if the "remember me" cookie is set. If it's set and everything seems legitimate, I go ahead and authenticate the user and log him in. This way the user doesn't even have to touch the login page. I don't know if this is what you're trying to do, but it might give you an idea.
If you already know the user_id and password when the user requests the login page then you could just send a location header
I am working on creating an iphone application which logins to we website and retrieves a table, and displays the content within the app. To view the table a Login is required. It seems the site is using Form-Baseds Authentication. WebSite's Login Screen
So How do I pass the login ID and pass from xcode to the to the site and retain the information so the user only needs to login once.
to remember the login credentials, the easiest way is to put them into a NSDictionary and write that to the application bundle, then read it later, when needed. Remember to give the users a chance to change their login credentials later on and at least think about encrypting the data.
As to the form-based login, the way to go would be to create a NSURLRequest to the login forms URL, if it is GET-based, simply do it like url.somewhere/form?user=foo&pass=bar, if it is POST-based, alter the created request and include the information needed in the POST-field.