Express app crashing in vs code vs real-world project - javascript

so here is the question, when I am testing my route in postman, I make mistakes on purpose to handle the errors, for example, I know the email is already taken but I test it and get an error that the email already exists...
when I try to enter the correct information, every time I click send in postman, it does not do anything, and I have to go back to vs code which there is an error there:
Cannot set headers after they are sent to the client
I have to resave it again in vs code, so I can test the route again in postman
now my question is in real life when I deploy my application to the host....when the user tries to register with an email that already exists, what will happen? the app will crash as well like in VS code or in the real server is different?

Related

Why do I get a `Cross-Origin-Request-Blocked` in the console, but the route works?

I have a React app that connects to a database through flask. The particular page I'm using is a "register user" type page. When I enter the info and click register, in the console I get the red CORS errors triggered. Yet, when I check the database, the data I submitted ends up there. I thought if I have a CORS error, nothing is talking to each other. On a high level, what is happening here?
You need to add cors to your flask app as your react app is running on local server, once you add cors your backend can work on any hosts .

How to implement basic login with Hasura on Heroku?

I'm completely new to web development and have never implemented anything that needs some kind of authentication before - basically, where the user can sign up, log in and log out.
I've stumbled across Hasura, a GraphQL server over Postgres and deployed it to Heroku. After creating some tables and populating them with data, I created a small Vue application that can query and mutate this data using vue-apollo, and this seems to work fine.
Now I want to restrict the use of the application, unless a user is logged in. I've read through the authentication / access control section of their documentation, but I don't really get how I can accomplish this... All the examples are seemingly created with React. They talk about having (not) logged in users, but I don't even get how to create one, or what a "logged in" user means in context. Furthermore it mostly mentions JWT and webhooks and I've never used them either... In my mind it should be pretty simple, but it seems overly complicated (it's probably just me being dumb).
All I want is a simple sign up form where a user can enter a username and password, and then use this username and password to log in in the future. How can I do this, and are there any examples of this with Vue and vue-apollo?

Getting a bad request bad request 400 when creating user(Firebase)

I am developing a web app and I'm using Firebase for that. Since I do not have a domain name yet, I'm trying to use my localhost. I can see localhost in OAuth redirect domains. Also the initializing part is working fine.
But when I create a user using firebase.auth().signInWithEmailAndPassword it shows [HTTP/2.0 400 Bad Request 447ms] when posting to https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword.
I'm new to web app development and Firebase web as well. Somebody please help me to do this using my localhost.
Thank you
You can create a user using firebase.auth().createUserWithEmailAndPassword(email, password). The email must be in a valid format. Don't forget that the password must be strong enough. Firebase returns auth/weak-password error code when using a weak password (less than 6 chars).
See also:
https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword

Sails.JS - retry on NTLM Auth failure?

I am currently writing a NodeJS application based on Sails.JS, and I'm using ntlm-express for NTLM authentication. This works perfectly fine when the authentication succeeds but in cases where it fails (for example, a Firefox user entering wrong credentials) ntlm-express returns a 500 error code, FireFox stores the credentials in its cache and the user is unable to login to the web app at all, since he's not getting a new prompt to enter credentials. The only way for the user to log in is to manually clear the authentication cache in FireFox and try again.
What I'd like to do is in cases where ntlm-express fails to authenticate the user, to prompt him again for credentials instead of returning 500.
Has anyone done something like this and can point me in the right direction? I found very little information online regarding this topic...
For anyone who runs into a similar issue, I managed to solve it by overriding the express-ntlm forbidden function to return a 401 instead of of 500 and editing the default Sails unauthorized.js response to also return a "WWW-Authenticate: NTLM" header.
That way I am forcing the client to retry NTLM negotiation until he gets it right...

Is it possible to test flow using Protractor without login flow?

I want to test flow using Protractor which occurs after login page, can I bypass or skip or avoid login while testing that flow?
One option would be to instead of opening a fresh browser instance each test, you open Firefox loading the Firefox profile previously saved when you was logged in. Aside from many other things, the profile contains cookies, that are usually used for login session validation:
log in to your application via Firefox
open Help->Troubleshooting Information->Profile Folder->Show in Finder (for Mac OS)
copy the path to the profile
use setFirefoxProfile HowTo to learn how to load this profile every time you run your tests
You can always mock the login, where details will depend on how the login is implemented.
If it is the session or key returned by the server, you can mock the server response by supplying that key, that will be accepted by your front end code, as if there was successful login.

Categories