Skip to content

Commit

Permalink
Added show password buttons swaraj-das#180
Browse files Browse the repository at this point in the history
  • Loading branch information
devarsheecodess committed Oct 8, 2024
1 parent e8d132d commit c1419fa
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 67 deletions.
34 changes: 30 additions & 4 deletions SignUp/signup.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ body {
height: 100vh;
color: white;
text-shadow: 1px 1px 2px #000;
}

.signup-container {

}.signup-container {
opacity: 0.75;
background-color: rgba(0, 0, 0, 0);
padding: 5rem;
Expand All @@ -31,6 +28,35 @@ body {
margin: auto;
}

.pass {
position: relative;
display: flex;
align-items: center;
}

.pass input {
width: 100%;
padding-right: 40px; /* Add padding to avoid text overlap with the button */
}

#showPasswordBtn,
#showPasswordBtn-conf {
position: absolute;
right: 10px; /* Align the button to the right of the input field */
top: 50%;
transform: translateY(-50%); /* Center vertically */
border: 1px solid transparent;
height: 30px;
font-size: 20px;
background-color: transparent; /* Make the button background transparent */
color: white;
}

#showPasswordBtn:hover,
#showPasswordBtn-conf:hover {
cursor: pointer;
}


@keyframes fadeIn {
from {
Expand Down
51 changes: 48 additions & 3 deletions SignUp/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<title>Sign Up for GamingTools</title>
<link rel="stylesheet" href="signup.css">
<link rel="shortcut icon" href="../images/logo.png" type="image/x-icon">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
</head>
<body>
<div class="signup-container">
Expand All @@ -21,16 +28,22 @@ <h1>Create Your Account</h1>
</div>
<div class="input-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
<div class="pass">
<input type="password" id="password" name="password" required>
<button id="showPasswordBtn"><i class="fa-regular fa-eye" id="passicon"></i></button>
</div>
</div>
<div class="input-group">
<label for="confirm-password">Confirm Password</label>
<input type="password" id="confirm-password" name="confirm-password" required>
<div class="pass">
<input type="password" id="confirm-password" name="confirm-password" required>
<button id="showPasswordBtn-conf"><i class="fa-regular fa-eye" id="passicon-conf"></i></button>
</div>
</div>
<button type="submit" class="signup-button">Sign Up</button>
</form>
<div class="links">
<a href="../login/login.html"><u>Already have an account? Login</u></a>
<a>Already have an account? <u><a href="../login/login.html">Login</a></u></a>
</div>
</div>

Expand Down Expand Up @@ -59,6 +72,38 @@ <h1>Create Your Account</h1>

} )

// Show password
document.getElementById("showPasswordBtn").addEventListener("click", () => {
const password = document.getElementById("password");
const icon = document.getElementById("passicon");

if (password.type === "password") {
password.type = "text";
icon.classList.remove("fa-regular", "fa-eye");
icon.classList.add("fa-solid", "fa-eye-slash");
} else {
password.type = "password";
icon.classList.remove("fa-solid", "fa-eye-slash");
icon.classList.add("fa-regular", "fa-eye");
}
});

// Show password-conf
document.getElementById("showPasswordBtn-conf").addEventListener("click", () => {
const password = document.getElementById("confirm-password");
const icon = document.getElementById("passicon-conf");

if (password.type === "password") {
password.type = "text";
icon.classList.remove("fa-regular", "fa-eye");
icon.classList.add("fa-solid", "fa-eye-slash");
} else {
password.type = "password";
icon.classList.remove("fa-solid", "fa-eye-slash");
icon.classList.add("fa-regular", "fa-eye");
}
});


const registeruser = async(user)=>{

Expand Down
28 changes: 23 additions & 5 deletions login/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ label {
font-size: 16px;
}

.pass{
display: flex;
}

#showPasswordbtn{
position: absolute;
right: 18%;
top: 51%;
background-color: transparent;
border: 1px solid transparent;
height: 30px;
font-size: 20px;
color: white;
}

#showPasswordbtn:hover{
cursor: pointer;
}

input[type="text"], input[type="password"] {
width: 100%;
padding: 0.75rem;
Expand Down Expand Up @@ -225,7 +244,7 @@ body{
font-size: 15px;
}

.links a:first-child: hover{
.links a:first-child:hover{
text-decoration: underline;
}

Expand Down Expand Up @@ -264,10 +283,9 @@ body{
}


.links a: hover {
.links a:hover {
color: #ff80ab;
}
}

.links {
margin-top: 18px;
Expand All @@ -288,14 +306,14 @@ body{
font-size: 15px;
}

.links a:first-child: hover{
.links a:first-child:hover{
text-decoration: underline;
}

.links a:not(:last-child) {
margin-right: 20px;
}

.links a: hover {
.links a:hover {
color: #ff80ab;
}
138 changes: 83 additions & 55 deletions login/login.html
Original file line number Diff line number Diff line change
@@ -1,71 +1,99 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Collect your GamingTools</title>
<link rel="stylesheet" href="login.css">
<link rel="shortcut icon" href="logo.png" type="image/x-icon">
</head>
<body>
<link rel="stylesheet" href="login.css" />
<link rel="shortcut icon" href="logo.png" type="image/x-icon" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
</head>
<body>
<div class="login-container">
<h1>Login to Your Account</h1>
<form action="#" method="post">
<div class="input-group">
<label for="username">Gmail</label>
<input type="text" id="gmail" name="username" required>
</div>
<div class="input-group">
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
</div>
<div ontouchstart="">
<div class="button">
<a href="#">Login</a>
</div>
</div>
</form>
<div class="links">
<a href="forgot.html" class="hal">Forgot Password?</a>
<a href="../SignUp/signup.html" class="hal2">Sign Up</a>
<h1>Login to Your Account</h1>
<form action="#" method="post">
<div class="input-group">
<label for="username">Gmail</label>
<input type="text" id="gmail" name="username" required />
</div>
<div class="input-group">
<label for="password">Password</label>
<div class="pass">
<input type="password" id="password" name="password" required />
<button type="button" id="showPasswordBtn">
<i class="fa-regular fa-eye" id="passicon"></i>
</button>
</div>
</div>
<div ontouchstart="">
<div class="button">
<a href="#">Login</a>
</div>
</div>
</form>
<div class="links">
<a href="forgot.html" class="hal">Forgot Password?</a>
<a href="../SignUp/signup.html" class="hal2">Sign Up</a>
</div>
</div>
</body>
</body>

<script>
<script>
const login = document.querySelector(".button");

login.addEventListener("click",(e)=>{
e.preventDefault();
login.addEventListener("click", (e) => {
e.preventDefault();

const email = document.querySelector("#gmail").value;
const password = document.querySelector("#password").value;
const userData = {
email,
password
}
console.log(userData)
loginUser(userData)
})
const email = document.querySelector("#gmail").value;
const password = document.querySelector("#password").value;
const userData = {
email,
password,
};
console.log(userData);
loginUser(userData);
});

// Show password
document.getElementById("showPasswordBtn").addEventListener("click", () => {
const password = document.getElementById("password");
const icon = document.getElementById("passicon");

if (password.type === "password") {
password.type = "text";
icon.classList.remove("fa-regular", "fa-eye");
icon.classList.add("fa-solid", "fa-eye-slash");
} else {
password.type = "password";
icon.classList.remove("fa-solid", "fa-eye-slash");
icon.classList.add("fa-regular", "fa-eye");
}
});

const loginUser = async (user)=>{
try{
const res = await fetch("http://localhost:5000/auth/signin",{
method:"POST",
credentials:"include",
redirect:"follow",
headers:{"content-type":"application/json"},
body:JSON.stringify(user)
})
const loginUser = async (user) => {
try {
const res = await fetch("http://localhost:5000/auth/signin", {
method: "POST",
credentials: "include",
redirect: "follow",
headers: { "content-type": "application/json" },
body: JSON.stringify(user),
});
if (!res.ok) {
throw new Error(`HTTP error! status: ${res.status}`);
throw new Error(`HTTP error! status: ${res.status}`);
}
const data = await res.json();


window.location.href="http://127.0.0.1:5500/Collect-your-GamingTools/index.html"
}catch(e){
window.location.href =
"http://127.0.0.1:5500/Collect-your-GamingTools/index.html";
} catch (e) {
console.log(e.message);
}
}
</script>
}
};
</script>
</html>

0 comments on commit c1419fa

Please sign in to comment.