Skip to content

Commit

Permalink
Merge pull request #364 from shriyadindi/remember-me
Browse files Browse the repository at this point in the history
Remember me" added to the signup and signin page connecting it to the local storage database for user authentication. #364
  • Loading branch information
Anuj3553 authored Nov 5, 2024
2 parents b371164 + bec6ca3 commit 7550852
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
19 changes: 18 additions & 1 deletion client/src/component/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ const Login = ({ mode, showAlert, isloggedin, setloggedin }) => {
}
}
};
document.querySelector('#login-btn').addEventListener('click', (event) => {
event.preventDefault();

const emailInput = document.getElementById('login-email');
const rememberMeCheckbox = document.getElementById('login-remember');

if (rememberMeCheckbox.checked) {
localStorage.setItem('rememberedEmail', emailInput.value);
} else {
localStorage.removeItem('rememberedEmail');
}

// Continue with your existing login logic...
});

return (
<div className="min-h-screen flex items-center justify-center mt-10" data-aos="zoom-in" data-aos-duration="1800">
Expand Down Expand Up @@ -139,7 +153,10 @@ const Login = ({ mode, showAlert, isloggedin, setloggedin }) => {

/>
</div>

<div class="form-check d-flex">
<input type="checkbox" class="form-check-input" id="login-remember" />
<label class="form-check-label" for="login-remember">Remember me</label>
</div>
<button className="submit" type="submit" disabled={loading}>
{loading ? <Spin size="small" /> : "Login"}
</button>
Expand Down
18 changes: 18 additions & 0 deletions client/src/component/Signup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ const Signup = ({ mode }) => {
},
body: JSON.stringify({ name, email, password }),
});
document.querySelector('#login-btn').addEventListener('click', (event) => {
event.preventDefault();

const emailInput = document.getElementById('login-email');
const rememberMeCheckbox = document.getElementById('login-remember');

if (rememberMeCheckbox.checked) {
localStorage.setItem('rememberedEmail', emailInput.value);
} else {
localStorage.removeItem('rememberedEmail');
}

// Continue with your existing login logic...
});
const json = await response.json();

if (json.success) {
Expand Down Expand Up @@ -238,6 +252,10 @@ const Signup = ({ mode }) => {
</div>

<br />
<div class="form-check d-flex">
<input type="checkbox" class="form-check-input" id="login-remember" />
<label class="form-check-label" for="login-remember">Remember me</label>
</div>

<button type="submit" className="signup-submit">
Sign Up
Expand Down
8 changes: 8 additions & 0 deletions client/src/css/Login.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ body {
text-align: center;
background-color: var(--form-bg, #fff);
}
.form-check {
align-items: center; /* Aligns checkbox and label vertically */
}

.form-check-input {
margin-right: 10px; /* Space between checkbox and label */
}


.title {
font-size: 3rem;
Expand Down
8 changes: 8 additions & 0 deletions client/src/css/Signup.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
.signup-link:hover {
color: #6366F1;
}
.form-check {
align-items: center; /* Aligns checkbox and label vertically */
}

.form-check-input {
margin-right: 10px; /* Space between checkbox and label */
}


@media (max-width: 600px) {
.signup-wrapper {
Expand Down

0 comments on commit 7550852

Please sign in to comment.