-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from fac-13/back-end
Added login and signup handlers + basic styling
- Loading branch information
Showing
12 changed files
with
230 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Add Comment</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Add Comment</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
<body> | ||
<nav> | ||
<a href="/">home</a> | ||
<a href="/public/comment.html">Add Comment</a> | ||
<a href="/public/signup.html">Sign Up</a> | ||
<a href="/public/login.html">Login</a> | ||
<nav class="nav__bar"> | ||
<button name="button" class="nav__button"> | ||
<a href="/">home</a> | ||
</button> | ||
<button name="button" class="nav__button"> | ||
<a href="/public/comment.html">Add Comment</a> | ||
</button> | ||
<button name="button" class="nav__button"> | ||
<a href="/public/signup.html">Sign Up</a> | ||
</button> | ||
<button name="button" class="nav__button"> | ||
<a href="/public/login.html">Login</a> | ||
</button> | ||
</nav> | ||
|
||
<form id="comment-form" action="/add-comment" method="POST"> | ||
<label for="country-input">Select Country</label> | ||
<input list="countries" name="country" id="country-input" required autocomplete="off"> | ||
<datalist id="countries"> | ||
|
||
</datalist> | ||
|
||
|
||
<label for="city-input">Select City</label> | ||
<input list="cities" name="city" id="city-input" required autocomplete="off"> | ||
<datalist id="cities"> | ||
|
||
</datalist> | ||
|
||
|
||
<label for="comment-input">Write your comment</label> | ||
<textarea name="comment" cols="30" rows="10" id="comment-input" required autocomplete="off"></textarea> | ||
|
||
<input type="submit" id="commentBtn" value="Comment"/> | ||
</form> | ||
|
||
<section class="section__form"> | ||
<form id="comment-form" action="/add-comment" method="POST"> | ||
<label for="country-input">Select Country</label> | ||
<input class="form__input" list="countries" name="country" id="country-input" required autocomplete="off"> | ||
<datalist id="countries"></datalist> | ||
<label for="city-input">Select City</label> | ||
<input class="form__input" list="cities" name="city" id="city-input" required autocomplete="off"> | ||
<datalist id="cities"></datalist> | ||
<label for="comment-input">Write your comment</label> | ||
<textarea class="form__textarea" name="comment" cols="30" rows="10" id="comment-input" required autocomplete="off"></textarea> | ||
<p class="error" aria-live="polite"></p> | ||
<input class="form__submit-button" type="submit" id="commentBtn" value="Comment" /> | ||
</form> | ||
</section> | ||
|
||
<script src="./comment.js"></script> | ||
</body> | ||
</html> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,50 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Log In</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Log In</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<nav> | ||
|
||
<body> | ||
<nav class="nav__bar"> | ||
<button name="button" class="nav__button"> | ||
<a href="/">home</a> | ||
</button> | ||
<button name="button" class="nav__button"> | ||
<a href="/public/comment.html">Add Comment</a> | ||
</button> | ||
<button name="button" class="nav__button"> | ||
<a href="/public/signup.html">Sign Up</a> | ||
</button> | ||
<button name="button" class="nav__button"> | ||
<a href="/public/login.html">Login</a> | ||
</nav> | ||
<section> | ||
</button> | ||
</nav> | ||
|
||
<section class="section__form"> | ||
|
||
<form class="login__form" action="/login" method="POST"> | ||
<form class="login__form" action="/login" method="POST"> | ||
|
||
<label for="username">Username:</label> | ||
<input class="form__input" id="username" type="text" required pattern="^[a-zA-Z0-9]+$" title="Please provide an alphanumeric name" | ||
name="username" value="" /> | ||
|
||
<label for="password">Password:</label> | ||
<input class="form__input" id="password" type="password" name="password" value="" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[!$%&(-/:-?_{}~])(?=.*[A-Z]).{9,}" | ||
title="Password should contain at least 9 characters, at least 1 capital letter, at least 1 lowercase letter, 1 number & a special character." | ||
/> | ||
|
||
<label for="username">Username: | ||
<input id="username" type="text" required pattern="^[a-zA-Z0-9]+$" title="Please provide an alphanumeric name" name="username" value=""/> | ||
</label> | ||
<label for="password">Password: | ||
<input id="password" type="password" name="password" value="" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[!$%&(-/:-?_{}~])(?=.*[A-Z]).{9,}" title="Password should contain at least 9 characters, at least 1 capital letter, at least 1 lowercase letter, 1 number & a special character."/> | ||
</label> | ||
|
||
<p class="error" aria-live="polite"></p> | ||
|
||
<input type="submit" id="loginButton" value="login"/> | ||
</form> | ||
<input class="form__submit-button" type="submit" id="loginButton" value="login" /> | ||
</form> | ||
|
||
</section> | ||
<script type="text/javascript" src="login.js"></script> | ||
</body> | ||
|
||
</section> | ||
<script type="text/javascript" src="login.js"></script> | ||
</body> | ||
</html> | ||
</html> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
html { | ||
margin: 0; | ||
padding: 0; | ||
color: #302f2f; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; | ||
} | ||
|
||
body { | ||
background: radial-gradient(#fbfcfd, #e7e8ef, #d2d5e2); | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
h1 { | ||
font-size: 2rem; | ||
} | ||
|
||
.nav__bar { | ||
height: 2rem; | ||
width: 100%; | ||
text-align: end; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
color: white; | ||
} | ||
|
||
.nav__button { | ||
font-size: 1.2rem; | ||
padding: 0.5%; | ||
margin: 0.5%; | ||
text-align: center; | ||
border: 2px solid black; | ||
background: #302f2f; | ||
color: #fbfcfd; | ||
font-weight: 700; | ||
border-radius: 0.6rem; | ||
} | ||
|
||
.header { | ||
text-align: center; | ||
padding-top: 35vh; | ||
margin: 0 1%; | ||
} | ||
|
||
form { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
margin:auto; | ||
} | ||
|
||
label { | ||
font-size: 1.2rem; | ||
padding: 1rem; | ||
font-weight: 700; | ||
} | ||
|
||
.form__submit-button { | ||
font-size: 1.5rem; | ||
text-transform: capitalize; | ||
margin: 5%; | ||
padding: 0.5%; | ||
text-align: center; | ||
border: 2px solid black; | ||
background: #302f2f; | ||
color: #fbfcfd; | ||
font-weight: 700; | ||
border-radius: 0.6rem; | ||
} | ||
|
||
.form__input { | ||
height: 2rem; | ||
padding: 0.2rem 0.5rem; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.form__textarea { | ||
padding: 0.2rem 0.5rem; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.form__submit-button:hover { | ||
color: #302f2f; | ||
background: #fbfcfd; | ||
border: 2px solid #302f2f; | ||
outline: none; | ||
} | ||
|
||
.section__results { | ||
display: flex; | ||
align-items: center; | ||
height: 100%; | ||
margin:auto; | ||
} | ||
|
||
.section__form { | ||
display: flex; | ||
align-items: center; | ||
height: 100%; | ||
margin:auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
const dbConnection = require("../src/database/db_connection.js"); | ||
|
||
const check_user_exists = (username, cb) => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const dbConnection = require("../src/database/db_connection.js"); | ||
|
||
const get_user_id = (username, cb) => { | ||
dbConnection.query( | ||
`SELECT id FROM users WHERE username = $1`, | ||
[username], | ||
(err, res) => { | ||
if (err) cb(err); | ||
else cb(null, res.rows); | ||
} | ||
); | ||
}; | ||
|
||
module.exports = get_user_id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.