Learn to Code via Tutorials on Repl.it!

← Back to all posts
How To Make A Simple Login And Sign Up System!
GameDev46

How To Make A Simple Login And Sign Up System!

So ages ago I wanted to make a working login and sign up system, but had no idea where to start! So I looked for some tutorials, but there were no really direct ones, only ones saying that it is really complicated! But here I am going to tech you directly how to make a simple login and sign up system which is stores on a webserver!

Starting up our server!

So for the server create a new Node.js server. No lets install some Node.js extensions for our server so it is ready to recieve requests!

In this code we have installed everything we will need to actually get the server up and running!

Receiving and responding to requests!

So now we need to setup our code to be able to listen for certain URLs and respond to them with he correct information!

The code we have just put in will now add and check login details from a replit database! Now all we have to do is get a personal HTTP for our server, which is simply done by adding this to the bottom of your code:

And click run and wait for the packages to install (It can take a few minutes) and then you should now have a web page saying "Server"!

Making requests from your project

This next bit of code would be done from a HTML, CSS and JS repl which would be separate to your node.ha server!

To communicate from the server you can use fetch requests, for example to check a users name and password the you would do:

and as for adding an account you pretty much do the same thing:

Find any errors in this?

If you have found any errors or are unsure of anything comment down below and I will be with you as soon as I can!

Remember to upvote if you like!!

Hope you have fun with this simple login and sign up tutorial!

Voters
lukVn
theduck2010
ThatGhost
DynamicSquid
GameDev46
Comments
hotnewtop
DynamicSquid

Nice! Quick question though, in your second apt.get thingy, what does this do:

GameDev46

@DynamicSquid It gets the url of the server and gets it ready for you to ask for everything after the ? at the end. Such as http://example.com/api/users?user=Test123

So you would be able to get the user variable from the url, which is equal to Test123

DynamicSquid

@GameDev46 Ah okay, cool!

ThatGhost

can you make an updated tutorial but with password encryption, or can ya send the npm package you used to encrypt passwords on chit-chat

ThatGhost

also, how do you send replies back to the website?

GameDev46

@ThatGhost I use bcrypt to hash the passwords:

GameDev46

@ThatGhost if you use the node.is res.send(); you can send whatever you want to for the fetch code to then display as the data