Skip to content

Commit d6347ed

Browse files
v1.0.0 (Better backend validation + better UX + buttons are FULLY responsive now + the fullname gets automatically capitalized)
1 parent 89a7a62 commit d6347ed

File tree

14 files changed

+156
-96
lines changed

14 files changed

+156
-96
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
22
package-lock.json
3-
*.env
4-
*stash*
3+
*.env

README.md

Lines changed: 76 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,76 @@
1-
<center><u><h1 style="font-family: Montserrat; font-size:4rem; font-weight:700;">SignUp + LogIn FORM</h1></u></center>
2-
3-
<i><p><h4 style="font-family: Montserrat; font-size:1.5rem; font-weight:500;">WIP (Work In Progress)</h4></p></i>
4-
5-
<p style="font-family: Montserrat; font-size:1.2rem; font-weight:400;">This is my first <i>FULLSTACK</i> project. <br>It is a simple signup + login functional form for the user.</p>
6-
7-
<ul style="padding-left:0;">
8-
<p style="font-family: Montserrat; font-size:1.2rem; font-weight:700;"><u>Technologies used:</u></p>
9-
10-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Handlebars (HTML)</li>
11-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">SaSS (CSS3)</li>
12-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">JS (ES6)</li>
13-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Node.JS</li>
14-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">MySQL (SQL)</li>
15-
</ul>
16-
17-
<ul style="padding-left:0;">
18-
<p style="font-family: Montserrat; font-size:1.2rem; font-weight:700;"><u>Libraries/frameworks:</u></p>
19-
20-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">FontAwesome for the icons.</li>
21-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">SweetAlerts for the alerts.</li>
22-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Normalize for adapting the webpage to all browsers.</li>
23-
</ul>
24-
25-
<ul style="padding-left:0;">
26-
<p style="font-family: Montserrat; font-size:1.2rem; font-weight:700;"><u>Node.JS modules used for development:</u></p>
27-
28-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Express.</li>
29-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Express-mysql-session</li>
30-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Express-session</li>
31-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Express-validator</li>
32-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Express-handlebars</li>
33-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Morgan</li>
34-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Nodemon</li>
35-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">MySQL</li>
36-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Passport</li>
37-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Passport-local</li>
38-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">TimeAgo.js</li>
39-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Dot.env</li>
40-
<li style="margin-left:1rem;font-family: Montserrat; font-size:1rem; font-weight:400;">Bcrypt.js</li>
41-
</ul>
1+
<u><h1>SignUp + LogIn FORM</h1></u>
2+
3+
This is my _first_ **FULLSTACK** project 💻
4+
5+
<u><h3>Description:</h3></u>
6+
7+
It's a signup and login web (with password and email **validation** in both **frontend and backend**):
8+
9+
* The web **automatically validates** the password in a dynamic way in the /signup page and in the /profile/edit page. If the validation isn't completed the user can't send the data.
10+
<center><em><u>Before validation:</u></em></center>
11+
12+
![Photo can't be loaded.](https://imgur.com/W4cIEhC.jpeg)
13+
14+
<center><em><u><b>After validation:</b></u></em></center>
15+
16+
![Photo can't be loaded.](https://imgur.com/Rng7VxJ.jpeg)
17+
18+
* There are **flashes** (SweetAlert2 personalized alerts) for every or almost every possibility (_the user introduced an already used email in the signup, he couldn't update his password, etc._).
19+
20+
* The **user can see all his data** once logged in and **edit** the **fullname or password** if he wants to (**in a dynamic way too**).
21+
22+
* The **password is encrypted** in the DB so in case anyone gains access to it he won't know the _"real (plaintext)"_ password (**salt of 12**).
23+
24+
**_Notes:_**
25+
* The web is fully responsive.
26+
* There are 2 functional icons in every form:
27+
* The clear button (it only shows if you focus on the email.)
28+
* The show/hide dynamic icon to show or hide the passwords you're typing.
29+
* The project has more small details that you can check for yourself.
30+
* Feel free to contact me on Twitter if you want to talk about this project or something else: [My twitter.](https://twitter.com/SergioAstGonz)
31+
32+
<u><h3>Things to do before trying out the project:</h3></u>
33+
34+
1. **Install MySQL** in your computer.
35+
2. Use the command `npm i` to install all the necessary node modules.
36+
3. **Execute** the script located in **/database/db.sql**
37+
4. Create a **.env** file with the following **variables**:
38+
* **DB_HOST:** the IP or hostname of the computer you're going to use for testing the project.
39+
* **DB_USER:** the username you use to access MySQL.
40+
* **DB_PASSWORD:** the password you use to access MySQL (You can leave it blank if you don't use any. But it has no be created.)
41+
* **DB_NAME:** the name of the DB where you're going to store the users (**_If you used the script this will be "mainDatabase"_**).
42+
* **SECRET:** the secret keyword for the session.
43+
* **PORT:** the port you're gonna use for testing the app. (I recommend **3000 || 5000 || 8080**)
44+
45+
Once you did all this you can **start using the project** with no problems.
46+
47+
<u><h3>Technologies used:</h3></u>
48+
49+
* **Handlebars** (_HTML_)
50+
* **SaSS/ScSS** (_CSS3_)
51+
* **JS** (_with ES6 features_)
52+
* **Node.JS**
53+
* **MySQL** (_SQL_)
54+
55+
<u><h3>Libraries/frameworks:</h3></u>
56+
57+
* **FontAwesome** for the icons.
58+
* **SweetAlert2** for the alerts.
59+
* **NormalizeCSS** for adapting the webpage to all browsers.
60+
61+
<u><h3>Node.JS modules used for development:</h3></u>
62+
63+
* Express.
64+
* Express-mysql-session
65+
* Express-session
66+
* Express-validator
67+
* Express-handlebars
68+
* Connect Flash
69+
* Morgan
70+
* Nodemon (_only in development_)
71+
* MySQL
72+
* Passport
73+
* Passport-local
74+
* TimeAgo.js
75+
* Dot.env
76+
* Bcrypt.js

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"description": "SignUp AND Login in Node.JS",
55
"main": "app.js",
66
"scripts": {
7-
"start": "node ./src/app.js",
8-
"dev": "nodemon ./src/app.js"
7+
"start": "node ./src/app.js"
98
},
109
"repository": {
1110
"type": "git",

src/lib/passport.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const time = require('./timeago');
77
/* REGEX for validations. */
88
const fullPasswordPattern = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.{1,}?[0-9])(?=.*?[#?!@$%&*\-+.,]).{8,30}$/g;
99
const fullnamePattern = /^(([A-Za-z]+[\-\']?)*([A-Za-z]+)?\s)+([A-Za-z]+[\-\']?)*([A-Za-z]+)?$/i;
10+
const fullEmailPattern = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
1011

1112
/* Login validation. */
1213
passport.use(
@@ -68,7 +69,7 @@ passport.use(
6869
It DOESN'T store anything in the DB */
6970
return done(null, false, req.flash('usedEmail', 'The email you introduced is already stored in our DB. Please, use a NEW email.'));
7071
}
71-
if (password.match(fullPasswordPattern)) {
72+
if (password.match(fullPasswordPattern) && email.match(fullEmailPattern)) {
7273
const result = await pool.query('INSERT INTO users set ?', [newUser]);
7374
newUser.id = result.insertId;
7475
return done(null, newUser, req.flash('successSignup', newUser.email));

src/public/css/editProfile.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)